Lesson-1 (Introduction to VBScript)

 

Microsoft Visual Basic Scripting Edition, the newest member of the Visual Basic family of programming languages, brings active scripting to a wide variety of environments, including Web client scripting in Microsoft Internet Explorer and Web server scripting in Microsoft Internet Information Server.

ActiveX Scripting

VBScript talks to host applications using ActiveX™ Scripting. With ActiveX Scripting, browsers and other host applications don't require special integration code for each scripting component. ActiveX Scripting enables a host to compile scripts, obtain and call entry points, and manage the namespace available to the developer. With ActiveX Scripting, language vendors can create standard language run times for scripting. Microsoft will provide run-time support for VBScript. Microsoft is working with various Internet groups to define the ActiveX Scripting standard so that scripting engines can be interchangeable. ActiveX Scripting is used in Microsoft® Internet Explorer and in Microsoft® Internet Information Server.

VBScript in Other Applications and Browsers

As a developer, you can license VBScript source implementation at no charge for use in your products. Microsoft provides binary implementations of VBScript for the 32-bit Windows® API, the 16-bit Windows API, and the Macintosh®. VBScript is integrated with World Wide Web browsers. VBScript and ActiveX Scripting can also be used as a general scripting language in other applications.

Here is an small example that defines a variable, uses input box to grab the users name, stores the user name in the defined variable and places it on the page.

<html>

<head>

<script language="vbscript">

Option Explicit

Sub GetUserName()

 dim name name=inputbox("Enter your name:")

 document.write("Your name is: " & name)

end sub

 </script>

</head>

 <body>

<script language="vbscript"> call GetUserName() </script>

 </body>

</html>

 

 Variable name was defined in the sub procedure GetUserName. Sub procedure is aware of whatever defined and evaluated in it. It does not return a value as the function does in vb script. Then the name variable was set to input box. This prompts an interface to the

 

                                                                                                                                                  

user and whatever user enters is stored back into the variable. Every sub must be closed with end sub. Option explicit catches any undeclared variables. It's good programming habit to declare all your variables. Finally, the sub is called. The expected result was to write the name on the browser