VBScript Data TypeNull, Empty, Boolean, ByteInteger, Long, Single, DoubleCurrency, Date, String, Object, Array, Error
Draft for Information Only
Content
VBScript Variant Subtypes Null Subtype Examples of Null Subtype Empty Subtype Examples of Empty Subtype Boolean Subtype Examples of Empty Subtype Byte Subtype Examples of Byte Subtype
VBScript Variant Subtypes
In general, data subtypes are always depend on implementing version, application, and platform. Provided information is based on Microsoft Windows 8.1 Pro x64, VBScript Version 5.8. Null subtype denotes no valid data. Empty subtype denotes no data. Boolean subtype denotes a 2-state data. And Byte subtype denotes a 1-byte data of an unsigned 8-bit Integer.
Null Subtype
The Null subtype refers to a Variant variable that contained is evaluated as Null without reference to any valid data reference or simply a variable contains no reference data.. In other words, the Null subtype refers to a Variant variable that have been set to contain no valid data.
The Null literal is evaluated as a Null value, which is used to denote a reference not pointing at any data value, or the absence of a data value for a Variant variable. The Null type has a single value, which is the Null value.
Usually, a Variant variable must be set to a Null value or a Null Variant variable specifically because a Variant variable always refers to a concrete reference data upon creation or initialization.
Examples of Null SubtypeBoth the Variant variable, 'a' created by Dim statement and the Variant variable 'b' created implicitly are not Null Variant variables. Both the Variant variable, 'a' created by setting to Null and the Variant variable 'b' created by assigning a Null Variant variable to are Null Variant variables. For a Null value, since a Null Variant variable always refers to no data, both the byte length and the byte value in String of a Null Variant variable is Null value also ASP VbScript Command:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script runat="server" language="VBScript">
Function printdata
cmda=array("IsNull(a)","IsEmpty(a)","LenB(a)","MidB(a,1)","IsNull(b)","IsEmpty(b)","LenB(b)","MidB(b,1)"):ucnt=UBound(cmda):call heading
vars="Dim a":dsp_x
vars="a=Null:b=a":dsp_x
End Function
Dim abb,cnt,cmda,cmp,dai,dlt,dte,dad,e,fnd,flg,fir,f_dw,gbd,hor,i,ild,k,mth,min,num,pnn,pi,sec,str1,str2,str,strs,tme,tmp,ucnt,var,vars,varx,wkd,x,z:varx=0
Function heading:If var=1 Then:tmp="":Else:tmp="<b>vars</b>":End If:For i=0 to ucnt:tmp=tmp&"<b>"&rmv_ctrl(cmda(i))&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows Server 2008 R2 Standard x64, Microsoft-IIS/7.5, VB Version 14.0<br />"&"<i>"&tmp&"</i>":End Function
Function dsp_x:Dim tmp_a,tmp_b,i:If varx=0 Then:Execute vars:End If:If var=1 Then:tmp_a="":Else:tmp_a=rmv_ctrl(vars):End If:For i=0 to ucnt:tmp_b=cmd_b(cmda(i)):if i/2=fix(i/2) Then:tmp_b="<b>"&tmp_b&"</b>":End If:tmp_a=tmp_a&tmp_b:Next:Response.Write "<i>"&tmp_a&"</i>":End Function
Function rmv_ctrl(blk_str):Select Case blk_str:Case chr(0):blk_str="NUL":Case chr(1):blk_str="SOH":Case chr(2):blk_str="STX":Case chr(3):blk_str="ETX":Case chr(4):blk_str="EOT":Case chr(5):blk_str="ENQ":Case chr(6):blk_str="ACK":Case chr(7):blk_str="BEL":Case chr(8):blk_str="BS":Case chr(9):blk_str="HT":Case chr(10):blk_str="LF":Case chr(11):blk_str="VT":Case chr(12):blk_str="FF":Case chr(13):blk_str="CR":Case chr(14):blk_str="SO":Case chr(15):blk_str="SI":Case chr(16):blk_str="DLE":Case chr(17):blk_str="DC1":Case chr(18):blk_str="DC2":Case chr(19):blk_str="DC3":Case chr(20):blk_str="DC4":Case chr(21):blk_str="NAK":Case chr(22):blk_str="SYN":Case chr(23):blk_str="ETB":Case chr(24):blk_str="CAN":Case chr(25):blk_str="EM":Case chr(26):blk_str="SUB":Case chr(27):blk_str="ESC":Case chr(28):blk_str="FS":Case chr(29):blk_str="GS":Case chr(30):blk_str="RS":Case chr(31):blk_str="US":Case chr(127):blk_str="DEL":End Select:rmv_ctrl=blk_str:If IsNull(blk_str) OR IsEmpty(Blk_str) OR blk_str="" OR IsNumeric(Blk_str) Then:Else:rmv_ctrl=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&")," "," "),"""","""),"<","<"),">",">"): End If :End Function
Function cmd_b(blk_str):cmd_b="["&cmd_x(blk_str)&"], "&cmd_x("TypeName("&blk_str&")"):End Function
Function cmd_x(blk_str):On Error Resume Next:Dim xans, tmp:xans="":tmp="":execute "xans="&blk_str:If Err.Number <> 0 Then:xans=cmd_x("TypeName("&blk_str&")"):Select Case xans:Case 9::Case Else:xans="error":End Select:End If:If IsArray(xans)=False Then:cmd_x=rmv_ctrl(xans): Else:tmp=lst_arry(xans):cmd_x=trim(tmp):End If:End Function
Function lst_arry(blk_str):Dim tmp,i,q:q="""":tmp="":For i=0 to UBound(blk_str):if VarType(blk_str(i))>1 And VarType(blk_str(i))<6 Then:q="'":End If:tmp=tmp&" "&q&rmv_ctrl(blk_str(i))&q:Next:lst_arry=trim(tmp):End Function
</script>
<title>Sample Page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<style type="text/css">
i {display:table-row}
u,b {display:table-cell}
</style>
</head>
<body>
<%call printdata %>
</body>
</html>
HTML Web Page Embedded Output:
Empty Subtype
The Empty subtype refers to a Variant variable that contained is evaluated as Empty with reference to a valid uninitialized data or simply a variable contains no initialized or assigned data. In other words, the Empty subtype refers to a Variant variable that have been created and set to contain a valid data but not yet assigned any data.
The Empty literal is evaluated as a Empty value, which is used to denote a reference pointing at a data value with nothing, or a nil data value for a Variant variable. The Empty type has a single value, which is the Empty value.
Usually, a Variant variable always refers to a concrete reference data upon creation implicitly or explicitly. However the value of the data is still uninitialized or has not yet assigned any data, because no information about the data is specified. An Empty value is genetic also. An Empty Variant variable is assigned 0 by VBScript when behaved as a numeric variable. However, an Empty Variant variable is assigned "", a zero-length string by VBScript when behaved as a string variable.
Examples of Empty SubtypeBoth the Variant variable, 'a' created by Dim statement and the Variant variable 'b' created implicitly are Empty Variant variables. For a Empty value, since a Empty Variant variable always refers to a data with no information, the byte length of a Empty Variant variable is always equal to zero, and the byte value in String is always equal to a zero-length strength ASP VbScript Command:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script runat="server" language="VBScript">
Function printdata
cmda=array("IsEmpty(c)","LenB(c)","MidB(c,1)","IsEmpty(d)","LenB(d)","MidB(d,1)"):ucnt=UBound(cmda):call heading
vars="Dim d":dsp_x
vars="c=0:d=""0""":dsp_x
vars="c=g:d=""g""":dsp_x
vars="c=g+1:d=g&""g""":dsp_x
End Function
Dim abb,cnt,cmda,cmp,dai,dlt,dte,dad,e,fnd,flg,fir,f_dw,gbd,hor,i,ild,k,mth,min,num,pnn,pi,sec,str1,str2,str,strs,tme,tmp,ucnt,var,vars,varx,wkd,x,z:varx=0
Function heading:If var=1 Then:tmp="":Else:tmp="<b>vars</b>":End If:For i=0 to ucnt:tmp=tmp&"<b>"&rmv_ctrl(cmda(i))&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows Server 2008 R2 Standard x64, Microsoft-IIS/7.5, VB Version 14.0<br />"&"<i>"&tmp&"</i>":End Function
Function dsp_x:Dim tmp_a,tmp_b,i:If varx=0 Then:Execute vars:End If:If var=1 Then:tmp_a="":Else:tmp_a=rmv_ctrl(vars):End If:For i=0 to ucnt:tmp_b=cmd_b(cmda(i)):if i/2=fix(i/2) Then:tmp_b="<b>"&tmp_b&"</b>":End If:tmp_a=tmp_a&tmp_b:Next:Response.Write "<i>"&tmp_a&"</i>":End Function
Function rmv_ctrl(blk_str):Select Case blk_str:Case chr(0):blk_str="NUL":Case chr(1):blk_str="SOH":Case chr(2):blk_str="STX":Case chr(3):blk_str="ETX":Case chr(4):blk_str="EOT":Case chr(5):blk_str="ENQ":Case chr(6):blk_str="ACK":Case chr(7):blk_str="BEL":Case chr(8):blk_str="BS":Case chr(9):blk_str="HT":Case chr(10):blk_str="LF":Case chr(11):blk_str="VT":Case chr(12):blk_str="FF":Case chr(13):blk_str="CR":Case chr(14):blk_str="SO":Case chr(15):blk_str="SI":Case chr(16):blk_str="DLE":Case chr(17):blk_str="DC1":Case chr(18):blk_str="DC2":Case chr(19):blk_str="DC3":Case chr(20):blk_str="DC4":Case chr(21):blk_str="NAK":Case chr(22):blk_str="SYN":Case chr(23):blk_str="ETB":Case chr(24):blk_str="CAN":Case chr(25):blk_str="EM":Case chr(26):blk_str="SUB":Case chr(27):blk_str="ESC":Case chr(28):blk_str="FS":Case chr(29):blk_str="GS":Case chr(30):blk_str="RS":Case chr(31):blk_str="US":Case chr(127):blk_str="DEL":End Select:rmv_ctrl=blk_str:If IsNull(blk_str) OR IsEmpty(Blk_str) OR blk_str="" OR IsNumeric(Blk_str) Then:Else:rmv_ctrl=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&")," "," "),"""","""),"<","<"),">",">"): End If :End Function
Function cmd_b(blk_str):cmd_b="["&cmd_x(blk_str)&"], "&cmd_x("TypeName("&blk_str&")"):End Function
Function cmd_x(blk_str):On Error Resume Next:Dim xans, tmp:xans="":tmp="":execute "xans="&blk_str:If Err.Number <> 0 Then:xans=cmd_x("TypeName("&blk_str&")"):Select Case xans:Case 9::Case Else:xans="error":End Select:End If:If IsArray(xans)=False Then:cmd_x=rmv_ctrl(xans): Else:tmp=lst_arry(xans):cmd_x=trim(tmp):End If:End Function
Function lst_arry(blk_str):Dim tmp,i,q:q="""":tmp="":For i=0 to UBound(blk_str):if VarType(blk_str(i))>1 And VarType(blk_str(i))<6 Then:q="'":End If:tmp=tmp&" "&q&rmv_ctrl(blk_str(i))&q:Next:lst_arry=trim(tmp):End Function
</script>
<title>Sample Page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<style type="text/css">
i {display:table-row}
u,b {display:table-cell}
</style>
</head>
<body>
<%call printdata %>
</body>
</html>
HTML Web Page Embedded Output:
Boolean Subtype
The Boolean subtype refers to a Variant variable that contained is evaluated as a two-state value, namely True or False. In other words, a Variant variable of Boolean subtype is used to specify a Variant variable contains only True or False literal. The True and False literals represent the two states of Boolean values, such as true/false, yes/no. or on/off. True and False literal are Boolean values, but "True" and "False" strings are character Strings only. However, "True" and "False" strings can also be converted to Boolean values by CBool function. Although a Boolean value can be evaluated as numeric value, all Boolean values are not stored as numbers and the stored values are also not intended to be equivalent to number. The stored data byte value of a Boolean value usually depends on the implementing platform. For example, .NET Framework and Visual Basic may behave differently in some case. For VBScript, a Boolean value can be converted to numeric value by CInt function. False literal is converted to 0 and True literal is converted to -1. A numeric value can also be converted to Boolean value by CBool function. However, number 0 is converted to False literal, while all other values are converted to True literal instead of only -1. In general, a Boolean Variant variable should only be worked with a two-state logical condition. The Boolean value of a Boolean Variant variable can be determined or set a condition. However the usage of Boolean variables or Boolean values should be restricted to the logical values, instead of the numeric representation of a Boolean value.
Examples of Empty SubtypeBoth True and False literals are Boolean value, but "True" and "False" strings are character Strings only. ASP VbScript Command:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script runat="server" language="VBScript">
Function printdata
cmda=array("CBool(a)","TypeName(a)","LenB(a)","MidB(a,1)","TypeName(b)","LenB(b)","MidB(b,1)"):ucnt=UBound(cmda):call heading
vars="a=True:b=False":dsp_x
vars="a=CInt(a):b=CInt(b)":dsp_x
vars="a=CBool(-1):b=CBool(0)":dsp_x
vars="a=CBool(1):b=CBool(2.8)":dsp_x
vars="a=""True"":b=""False""":dsp_x
vars="a=Yes:b=No":dsp_x
vars="a=1:b=0":dsp_x
vars="a=True+1:b=False+1":dsp_x
vars="a=True&""1"":b=False&""1""":dsp_x
vars="a=True&False:b=False&True":dsp_x
vars="a=True And False:b=False And True":dsp_x
vars="a=True Or False:b=False Or True":dsp_x
vars="a=True=False:b=False<>True":dsp_x
End Function
Dim abb,cnt,cmda,cmp,dai,dlt,dte,dad,e,fnd,flg,fir,f_dw,gbd,hor,i,ild,k,mth,min,num,pnn,pi,sec,str1,str2,str,strs,tme,tmp,ucnt,var,vars,varx,wkd,x,z:varx=0
Function heading:If var=1 Then:tmp="":Else:tmp="<b>vars</b>":End If:For i=0 to ucnt:tmp=tmp&"<b>"&rmv_ctrl(cmda(i))&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows Server 2008 R2 Standard x64, Microsoft-IIS/7.5, VB Version 14.0<br />"&"<i>"&tmp&"</i>":End Function
Function dsp_x:Dim tmp_a,tmp_b,i:If varx=0 Then:Execute vars:End If:If var=1 Then:tmp_a="":Else:tmp_a=rmv_ctrl(vars):End If:For i=0 to ucnt:tmp_b=cmd_b(cmda(i)):if i/2=fix(i/2) Then:tmp_b="<b>"&tmp_b&"</b>":End If:tmp_a=tmp_a&tmp_b:Next:Response.Write "<i>"&tmp_a&"</i>":End Function
Function rmv_ctrl(blk_str):Select Case blk_str:Case chr(0):blk_str="NUL":Case chr(1):blk_str="SOH":Case chr(2):blk_str="STX":Case chr(3):blk_str="ETX":Case chr(4):blk_str="EOT":Case chr(5):blk_str="ENQ":Case chr(6):blk_str="ACK":Case chr(7):blk_str="BEL":Case chr(8):blk_str="BS":Case chr(9):blk_str="HT":Case chr(10):blk_str="LF":Case chr(11):blk_str="VT":Case chr(12):blk_str="FF":Case chr(13):blk_str="CR":Case chr(14):blk_str="SO":Case chr(15):blk_str="SI":Case chr(16):blk_str="DLE":Case chr(17):blk_str="DC1":Case chr(18):blk_str="DC2":Case chr(19):blk_str="DC3":Case chr(20):blk_str="DC4":Case chr(21):blk_str="NAK":Case chr(22):blk_str="SYN":Case chr(23):blk_str="ETB":Case chr(24):blk_str="CAN":Case chr(25):blk_str="EM":Case chr(26):blk_str="SUB":Case chr(27):blk_str="ESC":Case chr(28):blk_str="FS":Case chr(29):blk_str="GS":Case chr(30):blk_str="RS":Case chr(31):blk_str="US":Case chr(127):blk_str="DEL":End Select:rmv_ctrl=blk_str:If IsNull(blk_str) OR IsEmpty(Blk_str) OR blk_str="" OR IsNumeric(Blk_str) Then:Else:rmv_ctrl=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&")," "," "),"""","""),"<","<"),">",">"): End If :End Function
Function cmd_b(blk_str):cmd_b="["&cmd_x(blk_str)&"], "&cmd_x("TypeName("&blk_str&")"):End Function
Function cmd_x(blk_str):On Error Resume Next:Dim xans, tmp:xans="":tmp="":execute "xans="&blk_str:If Err.Number <> 0 Then:xans=cmd_x("TypeName("&blk_str&")"):Select Case xans:Case 9::Case Else:xans="error":End Select:End If:If IsArray(xans)=False Then:cmd_x=rmv_ctrl(xans): Else:tmp=lst_arry(xans):cmd_x=trim(tmp):End If:End Function
Function lst_arry(blk_str):Dim tmp,i,q:q="""":tmp="":For i=0 to UBound(blk_str):if VarType(blk_str(i))>1 And VarType(blk_str(i))<6 Then:q="'":End If:tmp=tmp&" "&q&rmv_ctrl(blk_str(i))&q:Next:lst_arry=trim(tmp):End Function
</script>
<title>Sample Page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<style type="text/css">
i {display:table-row}
u,b {display:table-cell}
</style>
</head>
<body>
<%call printdata %>
</body>
</html>
HTML Web Page Embedded Output: Byte Subtype
The Byte subtype refers to a Variant variable that contained is evaluated as an unsigned 8-bit integer in 1-byte date with range in value from 0 through 255. In other words, a Variant variable of Byte subtype can be used to preserve binary data and store simple data that doesn't need to exceed the range 0 through 255.
For VBScript, Variant Integer subtype is the default subtype for integer value in the range -32768 through 32767 and has high priority over Variant Byte subtype. The CByte function can be used to convert valid numeric expressions to Byte values. And Variant Byte subtyp is therefore usually preserved for manipulating binary data. Examples of Byte SubtypeBoth True and False literals are Boolean value, but "True" and "False" strings are character Strings only. ASP VbScript Command:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script runat="server" language="VBScript">
Function printdata
On Error Resume Next:cmda=array("TypeName(a)","LenB(a)","MidB(a,1)","TypeName(CByte(a))","LenB(CByte(a))","MidB(CByte(a),1)"):ucnt=UBound(cmda):call heading
vars="a=-1":dsp_x
vars="a=0":dsp_x
vars="a=11":dsp_x
vars="a=254.5":dsp_x
vars="a=255":dsp_x
vars="a=255.4":dsp_x
vars="a=255.5":dsp_x
vars="a=256":dsp_x
vars="a=&h7F":dsp_x
vars="a=&HFF":dsp_x
vars="a=&o177":dsp_x
vars="a=&O377":dsp_x
End Function
Dim abb,cnt,cmda,cmp,dai,dlt,dte,dad,e,fnd,flg,fir,f_dw,gbd,hor,i,ild,k,mth,min,num,pnn,pi,sec,str1,str2,str,strs,tme,tmp,ucnt,var,vars,varx,wkd,x,z:varx=0
Function heading:If var=1 Then:tmp="":Else:tmp="<b>vars</b>":End If:For i=0 to ucnt:tmp=tmp&"<b>"&rmv_ctrl(cmda(i))&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows Server 2008 R2 Standard x64, Microsoft-IIS/7.5, VB Version 14.0<br />"&"<i>"&tmp&"</i>":End Function
Function dsp_x:Dim tmp_a,tmp_b,i:If varx=0 Then:Execute vars:End If:If var=1 Then:tmp_a="":Else:tmp_a=rmv_ctrl(vars):End If:For i=0 to ucnt:tmp_b=cmd_b(cmda(i)):if i/2=fix(i/2) Then:tmp_b="<b>"&tmp_b&"</b>":End If:tmp_a=tmp_a&tmp_b:Next:Response.Write "<i>"&tmp_a&"</i>":End Function
Function rmv_ctrl(blk_str):Select Case blk_str:Case chr(0):blk_str="NUL":Case chr(1):blk_str="SOH":Case chr(2):blk_str="STX":Case chr(3):blk_str="ETX":Case chr(4):blk_str="EOT":Case chr(5):blk_str="ENQ":Case chr(6):blk_str="ACK":Case chr(7):blk_str="BEL":Case chr(8):blk_str="BS":Case chr(9):blk_str="HT":Case chr(10):blk_str="LF":Case chr(11):blk_str="VT":Case chr(12):blk_str="FF":Case chr(13):blk_str="CR":Case chr(14):blk_str="SO":Case chr(15):blk_str="SI":Case chr(16):blk_str="DLE":Case chr(17):blk_str="DC1":Case chr(18):blk_str="DC2":Case chr(19):blk_str="DC3":Case chr(20):blk_str="DC4":Case chr(21):blk_str="NAK":Case chr(22):blk_str="SYN":Case chr(23):blk_str="ETB":Case chr(24):blk_str="CAN":Case chr(25):blk_str="EM":Case chr(26):blk_str="SUB":Case chr(27):blk_str="ESC":Case chr(28):blk_str="FS":Case chr(29):blk_str="GS":Case chr(30):blk_str="RS":Case chr(31):blk_str="US":Case chr(127):blk_str="DEL":End Select:rmv_ctrl=blk_str:If IsNull(blk_str) OR IsEmpty(Blk_str) OR blk_str="" OR IsNumeric(Blk_str) Then:Else:rmv_ctrl=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&")," "," "),"""","""),"<","<"),">",">"): End If :End Function
Function cmd_b(blk_str):cmd_b="["&cmd_x(blk_str)&"], "&cmd_x("TypeName("&blk_str&")"):End Function
Function cmd_x(blk_str):On Error Resume Next:Dim xans, tmp:xans="":tmp="":execute "xans="&blk_str:If Err.Number <> 0 Then:xans=cmd_x("TypeName("&blk_str&")"):Select Case xans:Case 9::Case Else:xans="error":End Select:End If:If IsArray(xans)=False Then:cmd_x=rmv_ctrl(xans): Else:tmp=lst_arry(xans):cmd_x=trim(tmp):End If:End Function
Function lst_arry(blk_str):Dim tmp,i,q:q="""":tmp="":For i=0 to UBound(blk_str):if VarType(blk_str(i))>1 And VarType(blk_str(i))<6 Then:q="'":End If:tmp=tmp&" "&q&rmv_ctrl(blk_str(i))&q:Next:lst_arry=trim(tmp):End Function
</script>
<title>Sample Page</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<style type="text/css">
i {display:Table-row}
u, b {display: Table-cell}
</style>
</head>
<body>
<%call printdata %>
</body>
</html>
HTML Web Page Embedded Output:
©sideway
ID: 180400016 Last Updated: 4/16/2018 Revision: 0
|
 |