Vbscript

What is VBScript? Introduction & Examples

What exactly is VBScript?
A scripting language called VBScript (Visual Basic Script) is being developed by Microsoft with the goal of creating dynamic web pages. It is a scripting language for the client-side, similar to JavaScript. VBScript is a simplified version of the Microsoft Visual Basic programming language. The syntax of VBScript is very similar to that of Visual Basic in terms of structure. If you want to make your webpage more lively and interactive, you can include VBScript in your HTML code to accomplish this.

VBScript is nothing more than a scripting language. So it is unable to execute its code by itself. It requires a more complex programming language in order to be hosted.
At the moment, there are three environments in which VB Scripts can be executed.

Windows Script Host (Windows Script Information Server) – The native hosting environment of the Windows operating system. IIS (Internet Information Server) – Microsoft’s web server.
IE (Internet Explorer) is a web browser. The simplest hosting environment in which we can run VBScript is http://localhost/vbscript/index.html.

How to Create a Simple VBScript?

Throughout this tutorial, you will only require two simple tools to create and execute VBScript code:

Internet Explorer – any version is acceptable, but IE6 or higher is recommended.
Text Editor – To write VBScript code, you can use a standard text editor such as Notepad++, Microsoft Expression Web, or even Notepad.
Let’s get started by creating a simple VB Script programme in Visual Basic.

In this tutorial series, we will demonstrate how to embed VBScript code within a very basic HTML code structure.

We can see VBScript in action in this manner by launching the corresponding HTML file in the Internet Explorer web browsing application.

VBScript Example:

Example of VBScript: Open your text editor (in this case, Notepad is used.) You can use whatever text editor you want to complete this task) and paste in the following lines of code.

<html> \s<head> \s<title>

My Very First VBScript Code!!!/title> /head> /body> My Very First VBScript Code!!!

script type=”text/vbscript”> Script type=”text/vbscript”
script> document.write(“Yes!!! I have begun learning VBScript.”) /script>

</body> \s</html>
As a result, your text editor will look something like this (the appearance and layout may differ depending on the text editor you are using):

Introduction to the VBScript programming language
VBscript Program with a Simple Interface
The HTML template for this programme is comprised of the sections that follow this one.

<html> \s<head> \s<title>

My Very First VBScript Code!!!/title> /head> /body> My Very First VBScript Code!!!

script type=”text/vbscript”> Script type=”text/vbscript”
script> document.write(“Yes!!! I have begun learning VBScript.”) /script>

</body> \s</html>
Only the section of code that begins with the word script is included in the VB Scripting code.

Whichever string sequence you choose to include in the document

TroubleShooting

write() will be displayed as page text by Internet Explorer.

This code will simply print the words “Yes!!!” on the screen. VB Scripting is something I’ve started learning.” says the browser page.

Navigate to the File menu and select the “Save” option. You will now see a window similar to this:

Introduction to the VBScript programming language
Filename: type in the name trial.html as the filename.
Save as the following file type: All Files.
To save your work, click the save button.
Following the successful click of the Save button, the file trial.html will be visible in the folder where you saved your file.

It is necessary to open the trial.html file in Internet Explorer in order to run the VB Scripting code that we have just created in this lesson.

If you have Internet Explorer set as your default browser, all you have to do is double-click the file trial.html to begin.

If you have another web browser set as your default browser, right-click the file and select Open With –> Internet Explorer as shown below:

Introduction to the VBScript programming language
It is possible that you will be presented with a message urging you to make Internet Explorer your default browser.

Now, when you open the Internet Explorer web browser, you will see a security warning similar to this:

Introduction to the VBScript programming language
You will be prompted to choose whether or not to make Internet Explorer your default browser after clicking “Allow Blocked Content.” You have the option of selecting Yes or No. On Internet Explorer, you will now see the message below.

Introduction to the VBScript programming language
Yes, you were successful in putting your first VBScript code into action.

TroubleShooting
If the code does not function properly –

Disadvantage of VBScript

To access developer tools, press the F12 key.
Scroll down in the left toolbar until you reach the “Emulation” settings page.
Document Mode should be changed from the default (“Edge”) to 10.
Make use of the following HTML code: html>head>meta title=”http-equiv=”x-ua-compatible” content=”IE=10″> http-equiv=”x-ua-compatible” content=”IE=10″> My Very First VBScript Code!!!/title> /head> /body> My Very First VBScript Code!!!

script type=”text/vbscript”> Script type=”text/vbscript”
Hello, World!” is written in document.write(“Hello, World!”) /script>

</body> \s</html>
The main disadvantage of VBScript is that, with the exception of Internet Explorer, the majority of browsers will not process VBScript code. In other words, if your website receives visitors who access it through a web browser other than Internet Explorer, such as Chrome, Firefox, or Opera, VBScript will be of limited use to them.

Aside from that, VBScript will not run on computers that are running operating systems other than Microsoft Windows, such as Linux or Mac OS X, among others.

VBScript, like any other scripting language, has gone through a number of transformations over the years.

VB Script is now the default scripting language for the Active Server Pages (ASP).

KEY LEARNING:

IMPORTANT LEARNING: Visual Basic Script (VB Script) is a scripting language developed by Microsoft.
In many ways, it is a simplified version of Microsoft Visual Basic, and the syntax of VBScript is very similar to that of Visual Basic.
The VBScript programme must be hosted on one of the following three environments:
Microsoft’s own web server software, IIS (Internet Information Server); WSH (Windows Scripting Host), the operating system’s native hosting environment, WSH (Windows Scripting Host).
IE (Internet Explorer) is the most straightforward hosting environment in which to run VBScript scripts.
Only Windows computers and the Internet Explorer browser are capable of running VB Script.
The most basic tools for creating and running VBScript are Internet Explorer and a text editor of your choice.