Re: Val() versus CLng, CInt or CByte



Rick Rothstein (MVP - VB) wrote:
Val is nice because it it will read a number followed by text, i.e. 23A becomes 23, instead of tossing up an error...

... which also has a dark side: e.g. Val("23E2") -> 2300, and Val("23E-2") -> 0.23

What's the "dark" side of correct interpretation of a floating point exponential notation??? (Puzzled as to why one would/could possibly expect/want any other result...)

I referred to the statement of the previous poster:
Val is nice because it it will read a number followed by text...

If you use Val to grab numbers from the left end of strings (a quite common usage of Val it seems to me), you might be surprised by the returns when the string happens to look like an exponential notation.

Would be far more surprised if it _didn't_ return the proper result when parsing a character string which does "look like" exponential notation.

I think Donald was referring to surprise someone might get parsing a set of code numbers where the digits in front of a letter were being sought and where the code numbers were something like this...

987A-30
654B-78
321E-12

That last one might be a surprise when pushed through the Val function.

Yeah, if finally dawned on me what his target was...my opinion is one needs to know the data one parses, but agree lots of folks seem to use easy way out and do get surprised on occasion because of it...

--
.



Relevant Pages

  • Re: Problem with `big oh estimates in number theory
    ... I hesitated over what word to use, and `deduction' may not ... let's not argue about a merely semantic problem ... Much to my surprise, I must ... the Onotation throws away vital information. ...
    (sci.math)
  • Maryland Ammo Shipment Question
    ... inexpensive 9mm ammo. ... To his surprise the supplier he was looking at ... had a notation that they could not ship to Montgomery County, ...
    (rec.guns)
  • Re: Val() versus CLng, CInt or CByte
    ... common usage of Val it seems to me), you might be surprised by the returns when the string happens to look like an exponential notation. ... parsing a character string which does "look like" exponential notation. ... I think Donald was referring to surprise someone might get parsing a set of code numbers where the digits in front of a letter were being sought and where the code numbers were something like this... ...
    (microsoft.public.vb.general.discussion)
  • Re: Infinite Loops and Explicit Exits
    ... What did surprise me, ... >Are you sure Robert, about the notation? ... I just checked Server Express ...
    (comp.lang.cobol)
  • Re: CYK & Context-Free Expressions
    ... Don't you think it's a little disingenuous to reply with a suggestion ... the n**3 bound for Earley parsing. ... appeared to me to be slide sets with little explanatory material. ... the notation was obvious. ...
    (comp.theory)