How to make a VBScript program?
Just like many other simple scripting languages, VBScript can be written on a simple word editor, like notepad and other such softwares (e.g. notepad++, Wordpad, etc.). Refer the following steps to get a better idea of making a VBScript program:
Step 1: Open up a word editor of your choice (Here, notepad is used).
Step 2: For now, here is a simple VBScript program that will make a simple message dialog box to appear on the screen. The code for such a program in VBScript is:
a = msgbox("Have a good day, fellow GFG reader!", 0, "Making a VBSript program")
Code Explanation: You can put anything as long as it follows the variable declaration rules in VBScript instead of “a” which is at the beginning of the above code. Effectively, We can break and understand the above code in the following manner:
put_any_Variable_name = msgbox("Your main text here", 0, "Your title text here")
To change the property of the dialog box with respect to what you need, refer the following data:
|0||Only “OK” button will be displayed.|
|1||OK and Cancel buttons will be displayed.|
|2||Abort, Retry, and Ignore buttons will be displayed.|
|3||Yes, No, and Cancel buttons will be displayed.|
|4||Yes and No buttons will be displayed.|
|5||Retry and Cancel buttons will be displayed.|
|16||Critical Message icon will be shown in the dialog box|
|32||Warning Query icon will be shown in the dialog box|
|48||Warning Message icon will be shown in the dialog box|
|64||Information Message icon will be shown in the dialog box|
|0||First button will become default|
|256||Second button will become default|
|512||Third button will become default|
|768||Fourth button will become default|
|0||Triggers the application modal (basically, the current application will stop working until the user responds to the dialog box)|
|4096||Triggers the System modal (basically, all applications will stop working until the user responds to the dialog box)|
Change “0” in the above written code with any of the numbers provided just above.
To get more than one above mentioned property in you dialog box, you can simple write, for example: “0+16”, instead of “0” in above code.
For reference, the code:
hydro = msgbox("Remeber to drink water!", 0+64, "Hydration Check")
will give the following output:
That’s it, we have just written a basic VBScript program that will display a dialog box as output. Now onto saving this program.
How to save a VBScript program?
Follow the steps given below to save a VBScript program:
Step 1: Press Ctrl + Shift + S on the keyboard, Or click File>Save As on the notepad window, this will open up a Save As dialog window asking where to save the current notepad document.
Step 2: Now write any file name of your choice for this notepad document but make sure you write .vbs as its extension. Make sure to add “.vbs” after writing the file name in the “File name:” field.
Step 3: Now, change the value of “Save as type:” field from “Text Documents (*.txt)” to “All Files (*.*)” by clicking on it with help of the drop down menu.
Step 4: Finally, click on save after choosing an appropriate location of where the file should be saved to.
How to run a VBScript program?
Now, this is a very simple thing to do, simply double click on the now saved .vbs file from wherever you saved it and voila! It will run and give you the following output:
- What is the difference between --save and --save-dev in Node.js ?
- VBScript | Introduction
- HTTP headers | Save-Data
- How to save an HTML 5 Canvas as an image on the server ?
- PHP | DOMDocument save() Function
- Save Files in ElectronJS
- Mongoose | save() Function
- p5.js | save() Function
- What is the meaning of --save for NPM install ?
- How to auto-save data when application is offline in Angular 8?
- Save Pages as HTML in ElectronJS
- How to make simple PUT request using fetch API by making custom HTTP library ?
- How to make Simple Website using Google AMP ?
- Create a web server and run PHP script on it using Raspberry Pi
- How to Install and Run Apache Kafka on Windows?
- Run Python script from Node.js using child process spawn() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.