VAL() ?

  • Thread starter Thread starter JethroUK©
  • Start date Start date
J

JethroUK©

Calculated field

Access seems to support the VAL function but it doesn't seem to work the
same as VB VAL i.e.

VAL("hello1") should return 1

anyone know the access function for returning the numeric part of a string?
 
Val() returns leading digits from a string.

For example:
Val("4k7.9E2")
returns just 4, not 47.92.

However, if you leave the k out of that string, you get an interesting
result.
 
JethroUK© said:
Calculated field

Access seems to support the VAL function but it doesn't seem to work
the same as VB VAL i.e.

VAL("hello1") should return 1

You're mistaken, Jethro. The VB Val() function, just as the Access VBA
Val() function, would return 0 for that expression. To the best of my
knowledge, it's the exact same function.

The Visual Basic Language Reference (looking in Visual Studio, not in
Access) says this about the Val() function: "The Val function stops
reading the string at the first character it can't recognize as part of
a number."
 
Throw-back to old programming languages. E represents "times ten raised to
the power", so 47.9E2 is 47.9 times ten raised to the power 2, or 4790. D
does the same (it represented that the resultant should be a Double, not a
Single)
 
Back
Top