Dealing With String Values

Dealing with script values such as "Hello There" is generally straightforward - unless your string value looks like a number, as in the following example.

Dim varTest
varTest = "12"
MsgBox TypeName(varTest)

Question is that why does the TypeName ( ) function returns "String" when we clearly passed it a numeric value of 12? This is because we placed value 12 in quotes. By placing it in quotes, we told VBScript that we mean for the value to be treated as a number:

Dim varTest
varTest = 12
MsgBox TypeName(varTest)

Dim varTest
varTest = CInt("12")
MsgBox TypeName(varTest)

Dim varTest
varTest = "12"
varTest = CInt(varTest)
MsgBox TypeName(varTest)

All three of these examples given above give the same result.

First
Next