digitallkp.blogg.se

Nicelabel vbscript example
Nicelabel vbscript example







Msgbox Var3 ' Displays 25 as Var3 is declared as Public When declaring a variable of type "public", Dim keyword is replaced by "Public".Įxample − In the following example, Var1 and Var2 are available at script level while Var3 is available across the associated scripts and procedures as it is declared as Public. Variables declared using "Public" Keyword are available to all the procedures across all the associated scripts. Msgbox Var3 ' Var3 has No Scope outside the procedure. Msgbox Var2 ' Displays 15 as Var2 is declared at Script level Msgbox Var1 ' Displays 10 as Var1 is declared at Script level Msgbox Var3 'Displays 25, the sum of two values. Functions would be dealt in detail in the upcoming chapters. Note − The scope of this chapter is to understand Variables. Variables declared using “Dim” Keyword at script level are available to all the procedures within the same script.Įxample − In the below example, the value of Var1 and Var2 are declared at script level while Var3 is declared at procedure level. Variables declared using “Dim” keyword at a Procedure level are available only within the same procedure. The scope of the variable plays a crucial role when used within a procedure or classes. Variables can be declared using the following statements that determines the scope of the variable. ' A Specific Time Stamp is assigned to a variable in the below example. ' The date is assigned to the variable DToday. ' A String Value ‘VBScript’ is assigned to the variable StrValue. ' Below Example, The value 25 is assigned to the variable. The String values should be enclosed within double quotes(")ĭate and Time variables should be enclosed within hash symbol(#) The numeric values should be declared without double quotes. The variable name on the left hand side followed by an equal to (=) symbol and then its value on the right hand side. Values are assigned similar to an algebraic expression. Hence, a user NEED NOT mention the type of data during declaration.Įxample 1 − In this Example, IntValue can be used as a String, Integer or even arrays.Įxample 2 − Two or more declarations are separated by comma(,) Since there is only ONE fundamental data type, all the declared variables are variant by default.

nicelabel vbscript example

Variables are declared using “dim” keyword. Variable Names should be unique in the declared context. Variables Should NOT contain a period (.) Variable names cannot exceed 255 characters. Variable Name must begin with an alphabet. VBScript has only ONE fundamental data type, Variant. A variable is a named memory location used to hold a value that can be changed during the script execution.









Nicelabel vbscript example