Re: inserting textbox value into bookmark
From: Jonathan West (jwest_at_mvps.org)
Date: 06/22/04
- Next message: Mable: "Macro overriding Xerox settings"
- Previous message: Jonathan West: "Re: Removing hyperlinks from a paragraph"
- In reply to: Alex Ivanov: "Re: inserting textbox value into bookmark"
- Next in thread: Alex Ivanov: "Re: inserting textbox value into bookmark"
- Reply: Alex Ivanov: "Re: inserting textbox value into bookmark"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 22 Jun 2004 18:15:47 +0100
"Alex Ivanov" <consul@collegeclub.com> wrote in message
news:u1gRxeHWEHA.3120@TK2MSFTNGP12.phx.gbl...
> & does the cstr in the background, you could save some typing efforts
> without calling it explicitly :)
> Me.Controls("txtLocation" & i).Text
> will do the same thing.
>
The & operator does something different, it deals with string concatenation.
What is happening if you omit the CStr function is that an implicit type
conversion is being done to the integer.
Personally, I prefer to do my type conversions explicitly, because then I
know exactly what is happening. 99 times out of a hundred it doesn't matter,
because the implicit type conversion does what I expect. But I would rather
be sure, because there are a number of different conversion functions, and
they produce slightly different results.
For instance, the Str() function does the same conversion as CStr(), except
that it puts a leading space on the resulting string if the number is
positive. Similarly, CLng returns an error if the string being converted
does not contain a valid number, but Val returns zero and does not throw an
error.
I prefer to use these functions explicitly rather than rely on VBA's default
behaviour. It's not impossible that the default might change in a future
version of Office, and even though I would want to hunt down the program
manager in Microsoft responsible for such a change, it would be too late
once the new version of Office had been released!
I'm not laying this down as a law - "Thou shalt use explicit type
conversions at all times", but it is a coding style which I use in my own
code, for the reasons I have described.
-- Regards Jonathan West - Word MVP www.intelligentdocuments.co.uk Please reply to the newsgroup
- Next message: Mable: "Macro overriding Xerox settings"
- Previous message: Jonathan West: "Re: Removing hyperlinks from a paragraph"
- In reply to: Alex Ivanov: "Re: inserting textbox value into bookmark"
- Next in thread: Alex Ivanov: "Re: inserting textbox value into bookmark"
- Reply: Alex Ivanov: "Re: inserting textbox value into bookmark"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|