Converting Other Data Types to Numeric Data
You can also convert some non-numeric data into numeric data. For example, suppose you have the following in a script.
Dim vValue
vValue = InputBox("Enter a number of servers")
At this point, you've no idea what vValue contains. You can try to convert it to a number, though. Consider the following examples.
If vValue contains "5 servers", CInt(vValue) would return 5, because the character 5 can be interpreted as an integer. If vValue contains "five", CInt(vValue) would return zero, because there are no numbers that can be converted to an integer. If vValue contains "5.2 servers", CInt(vValue) would return 5, because 5.2 can be interpreted as a number and the integer portion of that number is 5.
You can use any of the numeric conversion functions I've already covered to convert non-numeric data into numeric data. If vValue contains "five or 6 servers", CInt(vValue) would return zero, because the first characters cannot be interpreted as a number.
|