Sideway from Sideway

Draft for Information Only


VBScript Assingment Statement
 Set Statement
 = Operator

VBScript Assingment Statement

The assignment statements are set statement, and assigning equal to statement.

Set Statement

last updated 2017/11/18

to assigns an object reference to a variable or property, or to associate a procedure reference with an event.


Set objectvar = {objectexpression | New classname | Nothing}
Set object.eventname = GetRef(procname)


objectvar Required. Name of the variable or property; follows standard variable naming conventions. objectexpressionOptional. Expression consisting of the name of an object, another declared variable of the same object type, or a function or method that returns an object of the same object type.NewKeyword used to create a new instance of a class. If objectvar contained a reference to an object, that reference is released when the new one is assigned. The New keyword can only be used to create an instance of a class.classnameOptional. Name of the class being created. A class and its members are defined using the Class statement.NothingOptional. Discontinues association of objectvar with any specific object or class. Assigning objectvar to Nothing releases all the system and memory resources associated with the previously referenced object when no other variable refers to it.objectRequired. Name of the object with which eventname is associated.eventnameRequired. Name of the event to which the function is to be bound.procnameRequired. String containing the name of the Sub or Function being associated with eventname.


  • To be valid, objectvar must be an object type consistent with the object being assigned to it.
  • The Dim, Private, Public, or ReDim statements only declare a variable that refers to an object. No actual object is referred to until you use the Set statement to assign a specific object.
  • Generally, when you use Set to assign an object reference to a variable, no copy of the object is created for that variable. Instead, a reference to the object is created. More than one object variable can refer to the same object. Because these variables are references to (rather than copies of) the object, any change in the object is reflected in all variables that refer to it.
  • Using the New keyword allows you to concurrently create an instance of a class and assign it to an object reference variable. The variable to which the instance of the class is being assigned must already have been declared with the Dim (or equivalent) statement.
  • Refer to the documentation for the GetRef function for information on using Set to associate a procedure with an event.



= Operator

last updated 2017/11/17

Comparing 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.




expression1Any expression.expression2Any expression.variable1 Any variable or any writable property.


  • 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.




Examples of Set staement and assigning equal to statement using = Operator

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,strs,cmda
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 /sideway/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,"&","&amp;"),"  "," &nbsp;"),"""","&quot;"),"<","&lt;"),">","&gt;"): 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="Function reftest():reftest=""reftestok"":End Function:Function xfunc:a=b:xfunc=reftest:End Function":Execute vars:dsp_x
vars="b=""reftest"":Set a=GetRef(b)":dsp_x
HTML Web Page In-line Output:
Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /sideway/default.asp
varsa, TypeNameb, TypeNamexfunc, TypeNamea, TypeNameFunction reftest():reftest="reftestok":End Function:Function xfunc:a=b:xfunc=reftest:End Function[], Empty[], Empty[reftestok], String[], Emptyb="reftest":Set a=GetRef(b)[reftestok], Object[reftest], String[reftestok], String[reftest], Stringa=Null:b=3[], Null[3], Integer[reftestok], String[3], Integera=Null:b=5[], Null[5], Integer[reftestok], String[5], Integer


ID: 180400026 Last Updated: 2018/4/26 Revision:


Home (5)



HBR (3)



Hobbies (7)


Chinese (1097)

English (336)

Reference (66)


Hardware (149)


Application (187)

Digitization (24)

Numeric (19)


Web (618)new




Knowledge Base

Common Color (SC)

Html Entity (Unicode) (SC)

Html 401 Special (SC)

OS (388)new

MS Windows

Windows10 (SC)

.NET Framework (SC)

DeskTop (7)



Formulas (8)

Number Theory (206)

Algebra (20)

Trigonometry (18)

Geometry (18)

Calculus (67)

Complex Analysis (21)


Tables (8)


Mechanics (1)

Rigid Bodies

Statics (92)

Dynamics (37)

Fluid (5)

Fluid Kinematics (5)


Process Control (1)

Acoustics (19)

FiniteElement (2)

Biology (1)

Geography (1)

Copyright © 2000-2019 Sideway . All rights reserved Disclaimers last modified on 10 Feb 2019