Suite101

Introduction to VBScript


© Maxim Karetnikov

Introduction to VBScript

Introduction to VBScript

What is VBScript
VBScript stands for Visual Basic Scripting Edition. It is an interpreted script language from Microsoft basically intended to write dynamic interactive web pages . In general, script languages are easier and faster to code in than the more structured, compiled languages such as C and C++ and are ideal for smaller programs of limited capability or that can reuse and tie together with existing compiled programs.

History of VBScript
BASIC -  Beginners All-purpose Symbolic Instruction Code- was one of the first high level programming language . Microsoft corporation has provided a widespread use of BASIC (many programmers are still using  Quick Basic which combines simplicity and high efficiency). A worldwide "visualization" of  computers gave birth to Visual Basic for Windows Applications.  With the advent of  Internet and HTML, the development of active Web applications became available. Till 1996 JavaScript was the only language for this purpos. In 1996 VBScript has been derived from Visual Basic for active scripting. The version 3.0 of MS Internet Explorer has supported both  JavaScript and VBScript.    

From Basic to VBScript
A syntax of  Basic  is very similar to those of VBScript. For example, let us compare (while still without scrutinizing) a simple codes written in both languages for guessing some random number. In Basic code, a number is inserted from the keyboard, and the result is displayed on the screen.

10 CLS : RANDOMIZE
20 a = INT ( RND(1)*100+1 ) 
30 PRINT "Try to guess a number from 1 to 100"
50 INPUT v
60 IF a > v THEN PRINT "Your number is more" :
GOTO 40
70 IF a < v THEN PRINT "Your number is less" :
GOTO 40
80 IF a = v THEN PRINT "You did it!"
90 END

In VBScript code a number is input in the HTML element (text-entry field named "textbox" in the program). The result is displayed at the message window while pressing on the other HTML element (button named "but" in the program). 

<head>

<title> </title> <script language="vbscript"><!-- dim a dim v sub begin_onclick randomize a=int(rnd(1)*100+1) alert "Number is guessed" end sub sub but_onclick v = textbox.value v=cint(v) if a > v then alert "Your number is more" p = p + 1 end if if a < v then alert "Your number is less" p = p + 1 end if if a = v then document.write"<center>You did it!</center>" end if end sub --></script> </head> <body> <p><input type="text" name="textbox" size="20"></p> <p><input type="button" name="but" value="click when ready"></p> </body> </html>

The principle distinction between 2 codes is that VBScript inserted

Go To Page: 1 2


The copyright of the article Introduction to VBScript in VB Script is owned by . Permission to republish Introduction to VBScript in print or online must be granted by the author in writing.

Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo


Here's the follow-up discussion on this article: View all related messages

4.   Oct 28, 2002 2:36 AM
HI,
I need to use VB script for purposes like starting programs on the windows startup and entering keystrokes etc..
I need to know of a good editor to use as i don't intend to use VB scripts for a ...

-- posted by maxtorm


3.   Jun 11, 2002 1:32 PM
In response to message posted by ali_baba:

Well im kinda new with the whole VBScripting, DHTML, and JavaScripting, and i kinda disagr ...


-- posted by xXSwordFishXx


2.   Sep 4, 2000 6:35 AM

Dear JavaScript CE,

Thank you for your interest to VBScript page at Suite101. I share your opinion that experienced programmers mostly use JavaScript for DHTML. According to statistics, a ...


-- posted by kmaxim


1.   Aug 24, 2000 12:23 PM
Hi,

First of all, welcome to Suite101. I am the contributing editor of JavaScript at Suite101. I have some basic knowledge of Active Server Pages and that's why I know VBScript.

I agree that lea ...


-- posted by ali_baba





For a complete listing of article comments, questions, and other discussions related to Maxim Karetnikov's VB Script topic, please visit the Discussions page.