Link:http://output.to/sideway/default.asp?qno=180400021 Script, Scripting Language, VBScript elements, Server-Side VBScript Operator Comparison
VBScript Comparison Operators
The comparison operators are < Operator, <= Operator, > Operator, >= Operator, = Operator, <> Operator, and Is Operator.
< Operatorlast updated 11/17/2017Less than operator is used to create a value by comparing that the first expression is less than the second expression.
Syntaxexpression1<expression2 Argumentexpression1Any expression.expression2Any expression.Remarks- The expression returns True if expression1 is less than expression2.
- The expression returns False if expression1 is greater than or equal to expression2.
- The expression returns Null if either expression1 or expression2 is Null.
- If both expressions are numeric then perform a numeric comparison.
- If both expressions are strings then perform a string comparison.
- If one expression is numeric and the other is a string then the numeric expression is less than the string expression.
- If one expression is Empty and the other is numeric then the Empty expression is evaluated as 0 to perform a numeric comparison.
- If one expression is Empty and the other is a string then the Empty expression is evaluated as zero-length string, "" to perform a string comparison.
- If both expressions are Empty, then two expressions are equal.
Requirement1 <= Operatorlast updated 11/17/2017Less than or equal to operator is used to create a value by comparing that the first expression is less than or equal to the second expression.
Syntaxexpression1<=expression2 Argumentexpression1Any expression.expression2Any expression.Remarks- The expression returns True if expression1 is less than or equal to expression2.
- The expression returns False if expression1 is greater than expression2.
- The expression returns Null if either expression1 or expression2 is Null.
- If both expressions are numeric then perform a numeric comparison.
- If both expressions are strings then perform a string comparison.
- If one expression is numeric and the other is a string then the numeric expression is less than the string expression.
- If one expression is Empty and the other is numeric then the Empty expression is evaluated as 0 to perform a numeric comparison.
- If one expression is Empty and the other is a string then the Empty expression is evaluated as zero-length string, "" to perform a string comparison.
- If both expressions are Empty, then two expressions are equal.
Requirement1 > Operatorlast updated 11/17/2017Greater than operator is used to create a value by comparing that the first expression is greater than the second expression.
Syntaxexpression1>expression2 Argumentexpression1Any expression.expression2Any expression.Remarks- The expression returns True if expression1 is greater than expression2.
- The expression returns False if expression1 is less than or equal to expression2.
- The expression returns Null if either expression1 or expression2 is Null.
- If both expressions are numeric then perform a numeric comparison.
- If both expressions are strings then perform a string comparison.
- If one expression is numeric and the other is a string then the numeric expression is less than the string expression.
- If one expression is Empty and the other is numeric then the Empty expression is evaluated as 0 to perform a numeric comparison.
- If one expression is Empty and the other is a string then the Empty expression is evaluated as zero-length string, "" to perform a string comparison.
- If both expressions are Empty, then two expressions are equal.
Requirement1 >= Operatorlast updated 11/17/2017Greater than or equal to operator is used to create a value by comparing that the first expression is greater than or equal to the second expression.
Syntaxexpression1>=expression2 Argumentexpression1Any expression.expression2Any expression.Remarks- The expression returns True if expression1 is greater than or equal to expression2.
- The expression returns False if expression1 is less than expression2.
- The expression returns Null if either expression1 or expression2 is Null.
- If both expressions are numeric then perform a numeric comparison.
- If both expressions are strings then perform a string comparison.
- If one expression is numeric and the other is a string then the numeric expression is less than the string expression.
- If one expression is Empty and the other is numeric then the Empty expression is evaluated as 0 to perform a numeric comparison.
- If one expression is Empty and the other is a string then the Empty expression is evaluated as zero-length string, "" to perform a string comparison.
- If both expressions are Empty, then two expressions are equal.
Requirement1 = Operatorlast updated 11/17/2017Comparing equal to operator is used to create a value by comparing that the first and second expressions are equal to each other. While assigning equal to operation is used to assign a value to variable1 copied the second expressions.
Syntaxexpression1=expression2 variable1=expression2 Argumentexpression1Any expression.expression2Any expression.variable1 Any variable or any writable property.Remarks- The expression returns True if both expression1 and expression2 are equal to each other.
- The expression returns False if both expression1 and expression2 are not equal to each other.
- The expression returns Null if either expression1 or expression2 is Null.
- If both expressions are numeric then perform a numeric comparison.
- If both expressions are strings then perform a string comparison.
- If one expression is numeric and the other is a string then the numeric expression is less than the string expression.
- If one expression is Empty and the other is numeric then the Empty expression is evaluated as 0 to perform a numeric comparison.
- If one expression is Empty and the other is a string then the Empty expression is evaluated as zero-length string, "" to perform a string comparison.
- If both expressions are Empty, then two expressions are equal.
- The name on the left side of the equal sign can be a simple scalar variable or an element of an array. Properties on the left side of the equal sign can only be those properties that are writable at run time.
Requirement1 <> Operatorlast updated 11/17/2017Not equal to operator is used to create a value by comparing that the first and second expressions are not equal to each other.
Syntaxexpression1 <> expression2 Argumentexpression1Any expression.expression2Any expression.Remarks- The expression returns True if both expression1 and expression2 are not equal to each other.
- The expression returns False if both expression1 and expression2 are equal to each other.
- The expression returns Null if either expression1 or expression2 is Null.
- If both expressions are numeric then perform a numeric comparison.
- If both expressions are strings then perform a string comparison.
- If one expression is numeric and the other is a string then the numeric expression is less than the string expression.
- If one expression is Empty and the other is numeric then the Empty expression is evaluated as 0 to perform a numeric comparison.
- If one expression is Empty and the other is a string then the Empty expression is evaluated as zero-length string, "" to perform a string comparison.
- If both expressions are Empty, then two expressions are equal.
Requirement1 ExamplesExamples of VarType and TypeName functions ASP VbScript Command:<script runat="server" language="VBScript">
Dim vars,strs,cmda
cmda=array("a","b","a<b","a<=b","a>b","a>=b","a=b","a<>b")
Dim ucnt,tmp,i:ucnt=UBound(cmda):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 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp<br />"&"<i>"&tmp&"</i>"
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
vars="a=Null:b=3":dsp_x
vars="a=Empty:b=3":dsp_x
vars="a="""":b=3":dsp_x
vars="a=2:b=Null":dsp_x
vars="a=2:b=Empty":dsp_x
vars="a=2:b=""""":dsp_x
vars="a=Null:b=""b""":dsp_x
vars="a=Empty:b=""b""":dsp_x
vars="a="""":b=""b""":dsp_x
vars="a=""a"":b=Null":dsp_x
vars="a=""a"":b=Empty":dsp_x
vars="a=""a"":b=""""":dsp_x
vars="a=Null:b=Null":dsp_x
vars="a=Empty:b=Empty":dsp_x
vars="a="""":b=""""":dsp_x
vars="a=2:b=3":dsp_x
vars="a=2.2:b=3.3":dsp_x
vars="a=4:b=0.5":dsp_x
vars="a=4:b=-0.5":dsp_x
vars="a=4:b=-5":dsp_x
vars="a=-4:b=2":dsp_x
vars="a=-4:b=0.5":dsp_x
vars="a=-4:b=2.5":dsp_x
vars="a=-4:b=-2.5":dsp_x
vars="a=-4:b=-0.5":dsp_x
vars="a=-4:b=-2":dsp_x
vars="a=""-4"":b=""2""":dsp_x
vars="a=""a"":b=""b""":dsp_x
vars="a=""-4"":b=-2":dsp_x
vars="a=""a"":b=-2":dsp_x
vars="a=-4:b=""-2""":dsp_x
vars="a=-4:b=""b""":dsp_x
</script>
HTML Web Page In-line Output:Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp varsa, TypeNameb, TypeNamea<b, TypeNamea<=b, TypeNamea>b, TypeNamea>=b, TypeNamea=b, TypeNamea<>b, TypeNamea=Null:b=3[], Null[3], Integer[], Null[], Null[], Null[], Null[], Null[], Nulla=Empty:b=3[], Empty[3], Integer[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana="":b=3[], String[3], Integer[False], Boolean[False], Boolean[True], Boolean[True], Boolean[False], Boolean[True], Booleana=2:b=Null[2], Integer[], Null[], Null[], Null[], Null[], Null[], Null[], Nulla=2:b=Empty[2], Integer[], Empty[False], Boolean[False], Boolean[True], Boolean[True], Boolean[False], Boolean[True], Booleana=2:b=""[2], Integer[], String[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana=Null:b="b"[], Null[b], String[], Null[], Null[], Null[], Null[], Null[], Nulla=Empty:b="b"[], Empty[b], String[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana="":b="b"[], String[b], String[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana="a":b=Null[a], String[], Null[], Null[], Null[], Null[], Null[], Null[], Nulla="a":b=Empty[a], String[], Empty[False], Boolean[False], Boolean[True], Boolean[True], Boolean[False], Boolean[True], Booleana="a":b=""[a], String[], String[False], Boolean[False], Boolean[True], Boolean[True], Boolean[False], Boolean[True], Booleana=Null:b=Null[], Null[], Null[], Null[], Null[], Null[], Null[], Null[], Nulla=Empty:b=Empty[], Empty[], Empty[False], Boolean[True], Boolean[False], Boolean[True], Boolean[True], Boolean[False], Booleana="":b=""[], String[], String[False], Boolean[True], Boolean[False], Boolean[True], Boolean[True], Boolean[False], Booleana=2:b=3[2], Integer[3], Integer[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana=2.2:b=3.3[2.2], Double[3.3], Double[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana=4:b=0.5[4], Integer[0.5], Double[False], Boolean[False], Boolean[True], Boolean[True], Boolean[False], Boolean[True], Booleana=4:b=-0.5[4], Integer[-0.5], Double[False], Boolean[False], Boolean[True], Boolean[True], Boolean[False], Boolean[True], Booleana=4:b=-5[4], Integer[-5], Integer[False], Boolean[False], Boolean[True], Boolean[True], Boolean[False], Boolean[True], Booleana=-4:b=2[-4], Integer[2], Integer[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana=-4:b=0.5[-4], Integer[0.5], Double[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana=-4:b=2.5[-4], Integer[2.5], Double[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana=-4:b=-2.5[-4], Integer[-2.5], Double[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana=-4:b=-0.5[-4], Integer[-0.5], Double[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana=-4:b=-2[-4], Integer[-2], Integer[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana="-4":b="2"[-4], String[2], String[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana="a":b="b"[a], String[b], String[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana="-4":b=-2[-4], String[-2], Integer[False], Boolean[False], Boolean[True], Boolean[True], Boolean[False], Boolean[True], Booleana="a":b=-2[a], String[-2], Integer[False], Boolean[False], Boolean[True], Boolean[True], Boolean[False], Boolean[True], Booleana=-4:b="-2"[-4], Integer[-2], String[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Booleana=-4:b="b"[-4], Integer[b], String[True], Boolean[True], Boolean[False], Boolean[False], Boolean[False], Boolean[True], Boolean Is Operatorlast updated 11/17/2017Is same Object referenc operator is used to create a value by comparing that the first and second Object references are equal to each other.
Syntaxobject1 Is object2 Argumentobject1Any object name.object2Any object name.Remarks- The expression returns True if both object1 and object2 refer to the same Object.
- The expression returns False if both object1 and object2 refer to two different Object.
- Both objects can be Set to Nothing, but not Null or Empty.
Requirement1 ExamplesExamples of VarType and TypeName functions ASP VbScript Command:<script runat="server" language="VBScript">
Dim vars,strs,cmda,var:var=0
cmda=array("c","d","c Is d")
Dim ucnt,tmp,i:ucnt=UBound(cmda):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 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp<br />"&"<i>"&tmp&"</i>"
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
vars="strs=""htmlfile"":strs1=""\"":Set obj1=GetObject(strs1,strs): strs=""VBScript.RegExp"": Set obj2= CreateObject(strs): Set c=obj1: Set d=obj1":dsp_x
vars="Set c=obj1:Set d=obj2":dsp_x
vars="Set c=obj1:Set d=Nothing":dsp_x
vars="Set c=Nothing:Set d=Nothing":dsp_x
vars="c=Null:Set d=Nothing":dsp_x
vars="c=Empty:Set d=Nothing":dsp_x
vars="c="""":Set d=Nothing":dsp_x
vars="c=Null:d=Null":dsp_x
vars="c=Empty:d=Empty":dsp_x
</script>
HTML Web Page In-line Output:Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp varsc, TypeNamed, TypeNamec Is d, TypeNamestrs="htmlfile":strs1="\":Set obj1=GetObject(strs1,strs): strs="VBScript.RegExp": Set obj2= CreateObject(strs): Set c=obj1: Set d=obj1[[object]], HTMLDocument[[object]], HTMLDocument[True], BooleanSet c=obj1:Set d=obj2[[object]], HTMLDocument[IRegExp2], IRegExp2[False], BooleanSet c=obj1:Set d=Nothing[[object]], HTMLDocument[Nothing], Nothing[False], BooleanSet c=Nothing:Set d=Nothing[Nothing], Nothing[Nothing], Nothing[True], Booleanc=Null:Set d=Nothing[], Null[Nothing], Nothing[error], errorc=Empty:Set d=Nothing[], Empty[Nothing], Nothing[error], errorc="":Set d=Nothing[], String[Nothing], Nothing[error], errorc=Null:d=Null[], Null[], Null[error], errorc=Empty:d=Empty[], Empty[], Empty[error], error
|
|