Introduction to VBScript

Tuesday, October 26, 2010 by Tan
I am here today to give you a heads up about VBScript. What are VBScripts? As the name suggests, this is a script version on Visual Basic or VB. We can hence say that Visual Basic Script is a subset of the Visual Basic language.

VBScript is also a scripting language that can be used as an alternative to Java Script that runs in Internet Explorer for Windows OS. What is the relation between Internet Explorer, Windows Operating System and VBScript? Yes, you guessed it right. It is a scripting language supported freely on Windows OS and IE, and all of these are developed by Microsoft. Hence, you can see that VBScripts work only on a Windows hosting platform.

One advantage with VBScript for those who are already familiar with Java Scripts is that VBScript and Java Script blocks can be used together in one document, and functions, statements and variables in these blocks can be related to one another.

The applications written using VBScript are saved as .VBS files that can be executed with either WSCRIPT or CSCRIPT. These two are nothing but Windows Scripting Host programs. VBS applications can execute on computers where Microsoft Windows OS is installed, using these Windows Scripting Hosts.

To know more about VBScripts, feel free to visit the Wikipedia Link. It gives you good insights about the language, its history and much more.

Try this simple code. This will give the squares of first five digits:
Paste the following codes in between < type="text/vbscript"> and < /script >

Dim sText(5)
For i=1 To 5
sText(i)="Square of " & i & "is: " & i*i

For i=1To 5
document.write(sText(i) & " ")

Simple huh! If you want to see a bit more complicated one with some user interface, just replace statement 8 above with the following statement. It asks for 5 phrases one after the other and once you input them, they will show the result in a list.

sText(i)=inputbox("Enter Phrase # " & i)
Try this with names of books, friends or anything that you want and see VBScript in business.

PS: You may add a tag <> at the top and < /html > at the end and save the file as a html file and run it using Internet Explorer. This also works that way. Let me know you are reading. Do comment in your views...
Posted in Labels: , , , | 0 Comments »

0 Reviews: