How To Evaluate Numeric Expressions Stored as a String (159974)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
This article was previously published under Q159974 SUMMARY
Given a string expression, the Val function returns the number contained in
that string. However, if it encounters a character that is not a number
or part of a number, it ignores the rest of the string. For example,
Val("2") returns the number 2, but Val("2+2") also returns the number 2,
and Val("(2+2)") returns the number 0.
This article describes how to obtain the actual value of a numeric
expression that is stored as a String by using the existing features in the
Excel Object Model.
Modification Type: | Minor | Last Reviewed: | 7/1/2004 |
---|
Keywords: | kbhowto kbprogramming KB159974 |
---|
|