Previous | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Next |
Defining the Scope of a Variable in VB Script
Variables in VB Script is used for assigning values and using them for different operations. The scope of Variable in VB Script can be classified as Local Variable and Global Variable.
In any programming language there is a scope for everything used in the code and likewise in VB scripting also there is a scope for a variable. The scope of a variable determines where it should be used in the script. The scope of a variable depends on its declaration in the script. The scope of a variable is of two types.
1. Procedure Level Variable.
2. Script Level Variable.
Procedure Level Variables are also called as Local Variables because they can only be used in the Procedure or Function. If a variable exists within a function then it works for that function meaning it is used within the function and the value gets destroyed once it comes out of the function.
Script Level variables are also called as Global Variables and they can be called anywhere in the script. These variables can be used even in the Functions but based on the passby values. These Script Level variables are always declared out side the procedures.
Previous | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Next |
3 comments:
Hi kiran,
Thanks for posting vb scripts in such a easy way .Can u post script for revere the string?
keep it up.
Regards,
kanchan
Vb Script to print a string in reverse way.
Method 1
MyStr = InputBox(“Enter a string to be reversed”)
y = Len(MyStr)
For x = y To 1 Step -1
char = Mid(MyStr,x,1)
NewStr = NewStr & char
Next
msgbox "The reverse string of"&mystr&"is "&newstr
Vb Script to print a string in reverse way.
You can use the built in function of VB Script Library i.e. strReverse
Method 2
val=Inputbox("Please enter any number or a string")
a = strReverse(val)
msgbox "The reverse of "&val& " is: "&a
Post a Comment