By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,036 Members | 960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,036 IT Pros & Developers. It's quick & easy.

Overworking the expression service?

P: n/a
MLH
MyLogEnt = "New vehicle (VID #" & GetCurrentVehicID() & ") added by "
& CurrentUser()

The expression service obviously handles the coercion of the long
integer returned by GetCurrentVehicID() to a string that is normally
expected in a concat. Just because it works doesn't mean that its
good programming. Am wondering what you think?
Sep 24 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Access (and VBA) makes implicit type conversions constantly (well -
depending on the dilligence of the developer perhaps).
You'll have to try a lot harder than that to overwork the expression
service.

It would be more explicit to have

MyLogEnt = "New vehicle (VID #" & CStr(GetCurrentVehicID()) & ") added by "
& CurrentUser()

But as I said - that's a development choice.

"MLH" <CR**@NorthState.netwrote in message
news:90********************************@4ax.com...
MyLogEnt = "New vehicle (VID #" & GetCurrentVehicID() & ") added by "
& CurrentUser()

The expression service obviously handles the coercion of the long
integer returned by GetCurrentVehicID() to a string that is normally
expected in a concat. Just because it works doesn't mean that its
good programming. Am wondering what you think?

Sep 24 '06 #2

P: n/a
"Good programming" is likely to evoke opinions--which may well be what
you want.

Coding is a means to me, not an end. So in this case, I seldom
explicitly convert to a string. If I want something to be formatted,
yes. If I want to be sure there is no extra space, I mostly use Format()
without format string.

But Cstr() only takes a little extra time here, without supplying value.
Maybe, all this said, leaving the expression as is is the best.

MLH schreef:
MyLogEnt = "New vehicle (VID #" & GetCurrentVehicID() & ") added by "
& CurrentUser()

The expression service obviously handles the coercion of the long
integer returned by GetCurrentVehicID() to a string that is normally
expected in a concat. Just because it works doesn't mean that its
good programming. Am wondering what you think?
--
Bas Cost Budde
Holland
Sep 25 '06 #3

P: n/a
Bas Cost Budde <b.*********@dev.null.comwrote in
news:ef**********@localhost.localdomain:
"Good programming" is likely to evoke opinions--which may well be
what you want.

Coding is a means to me, not an end. So in this case, I seldom
explicitly convert to a string. If I want something to be
formatted, yes. If I want to be sure there is no extra space, I
mostly use Format() without format string.

But Cstr() only takes a little extra time here, without supplying
value. Maybe, all this said, leaving the expression as is is the
best.
I think it's always best to explicitly coerce values:

1. if you don't, the results may be unexpected (though string
coercion is probably the safest of all).

2. you're dependent on changes in behavior of the way coercion may
work in the same code run on future versions of VB.

3. explicit coercion shows that you've considered what's going on,
and makes the code easier for another programmer to read.

4. having a policy of explicit coercion makes you think more about
implicit coercion and, in my opinion, makes you a better coder for
doing that extra thinking -- you're more likely to catch possible
errors if you're in the habit of never depending on implicit
coercion.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 25 '06 #4

P: n/a
MLH wrote:
MyLogEnt = "New vehicle (VID #" & GetCurrentVehicID() & ") added by "
& CurrentUser()

The expression service obviously handles the coercion of the long
integer returned by GetCurrentVehicID() to a string that is normally
expected in a concat. Just because it works doesn't mean that its
good programming. Am wondering what you think?
I think that all data are strings.

Sep 25 '06 #5

P: n/a

Lyle Fairfield wrote:
MLH wrote:
MyLogEnt = "New vehicle (VID #" & GetCurrentVehicID() & ") added by "
& CurrentUser()

The expression service obviously handles the coercion of the long
integer returned by GetCurrentVehicID() to a string that is normally
expected in a concat. Just because it works doesn't mean that its
good programming. Am wondering what you think?

I think that all data are strings.
As a general rule, I try to get someone else to do my thinking for me.
Takes too much effort to figure things out on my own.

Sep 26 '06 #6

P: n/a
"Lyle Fairfield" <ly***********@aim.comwrote
I think that all data are strings.
Ah, "string theory." I didn't know you were a physicist, Lyle.

Larry
Sep 26 '06 #7

P: n/a

Larry Linson wrote:
"Lyle Fairfield" <ly***********@aim.comwrote
I think that all data are strings.

Ah, "string theory." I didn't know you were a physicist, Lyle.

Larry
You could just string along with what I said then, Larry.

Sep 27 '06 #8

P: n/a
I do play some string instruments, though. I didn't realize until now I
could rely on implicit coercion, playing the base :)

--
Bas Cost Budde
Holland
Sep 27 '06 #9

P: n/a
Bas Cost Budde wrote:
I do play some string instruments, though. I didn't realize until now I
could rely on implicit coercion, playing the base :)
I play only with g-strings. I hope there is no coercion, implicit or
otherwise.
But more often than not I don't get to first base at all.

Sep 27 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.