Re: Val() versus CLng, CInt or CByte




"Jack" <replyto@it> wrote in message
news:e%23n6WrpGIHA.6068@xxxxxxxxxxxxxxxxxxxxxxx
Hello,
Which is preffered:
Val() or CLng () CInt,CByte
?
Using Val() is very convenient, because it accommodates all other numeric
dimensions.
Are there any restrictions or negatives of using it?
If there are, when should I use Val() and when the others?
Yours thoughts, please
Jack


CLng, et.al., are locale aware, so when in Rome, they will do as the Romans.
That is, they will recognize the use of comma as a decimal point, and period as
a thousand separator, in those locales where they do that. They are also
reasonably self documenting.


Val is nice because it it will read a number followed by text, i.e. 23A becomes
23, instead of tossing up an error. Since it returns a double, there will be an
implicit type conversion of the result to the actual desired type.

Depends on what you want/need.



.



Relevant Pages

  • Re: Type mismatch error
    ... CLng() is Locale aware and is intolerant of 'invalid' characters ... In my opinion Locale awareness should be explicitly supplied by the ...
    (microsoft.public.vb.general.discussion)
  • Re: Val() versus CLng, CInt or CByte
    ... Steve Gerrard wrote: ... Valor CLng CInt,CByte ... there will be an implicit type conversion of the result to ... MIght it be efficient enough to not necessarily need long filters for ...
    (microsoft.public.vb.general.discussion)
  • Val() versus CLng, CInt or CByte
    ... Valor CLng CInt,CByte ... because it accommodates all other numeric ... dimensions. ... Jack ...
    (microsoft.public.vb.general.discussion)
  • Re: How to Convert 8bit into 6bit AIS encapsulation?
    ... pre-determined number for the Local data to be able to function. ... Replace CLng() with Val ... CLng is locale aware and barfs given any opportunity ...
    (microsoft.public.vb.general.discussion)