In VBScript, the values are dynamic typed meaning that the values can be changed at runtime for any variable. For example, a numerical variable can be converted on the fly to be used as a string type like this, dim a : a = 2 & “3” which produces string 23 but when Msgbox a + 1 this will output value 24 which shows that the string type will be used as a number in the arithmetic expression.
The following VBScript function IsBlank will return True if the passed parameter (value) is any of the following: Empty, NULL, Zero (number) or “”.
Function IsBlank(Value)
'Returns True if Empty or NULL or Zero
If IsEmpty(Value) or IsNull(Value) Then
IsBlank = True
ElseIf IsNumeric(Value) Then
If Value = 0 Then ' Special Case
IsBlank = True ' Change to suit your needs
End If
ElseIf IsObject(Value) Then
If Value Is Nothing Then
IsBlank = True
End If
ElseIf VarType(Value) = vbString Then
If Value = "" Then
IsBlank = True
End If
Else
IsBlank = False
End If
End Function
We use IsNumeric to check for numbers, the IsObject to check of objects and VarType()=vbString to determine if it is a string type.
–EOF (The Ultimate Computing & Technology Blog) —
Last Post: Check Given String has Repeated Characters
Next Post: Timeout Utility in Windows Command Shell