Second Call TypeName ( ) Function

Din lngAge
lngAge = InputBox("Plese enter your age in years")
MsgBox "TypeName After InputBox: " & TypeName(lngAge)
If IsNumeric(lngAge) Then
lngAge = lngAge + 50
MsgBox "TypeName after Adding 50: " &TypeName(lngAge)
MsgBox "In 50 years you will be " & lngAge & "years old."
MsgBox "Sorry, but you did not enter a valid number."
End If

The second call to the TypeName ( ) function comes after we add 50 to it, and shows that the subtype is Double. Wait a minute - Double? Why Double? Why not once of the whole number subtypes, such as Integer or Long? I didn't introduce any decimal places in this math? Why would VBScript implicitly coerce the subtype into Double? The answer is because VBScript determined that this was the best thing to do. Since we did not use a conversion function to explicitly tell VBScript to change the variable to one subtype or another, it evaluated the situation and chose the subtype that it thought was best. You have to be careful, because it can be tricky to predict exactly which subtype VBScript will choose.