People might thought that “notepad.exe” is just a notepad. What if I told you that you can use it to create VBScript Message Box?
In this article, I will show you the easiest steps to create a message box using VBScript.
VBScript Message Box Syntax
Even though VBScript is already exists since years ago, you still can use it on latest Windows version. The only syntax or programming line is x=msgbox([prompt],[button],[title]).
- Prompt. This is the dialogue or the content box.
- Button. Button/Action to display. But only use constant or value in the MsgBox Constants
- Title. This is where the title for the message box.
How To Create VBScript Message Box
1 – Create new “text document” or text file using notepad.
You can simply right click on your desktop, then navigate to “New >”, then click “Text Document”
2 – Enter the syntax into text file.
As mentioned before, enter the msgbox syntax into text file. For example, you can enter syntax like this >> x=msgbox(“This is my text”,0,”Title Here”).
3 – Save the file as VBS.
At the top of notepad, click “File > Save As”. Choose where would you like to save the VBScript file. In this example, I will save the file at my Desktop.
Then rename the file as what you want. Before you click save, you need to change on two things as below:
- change the file format to .vbs
- select “All Files” for save as type
- select encoding “ANSI”
Once done changed, click save.
Voila! Now your message box is done.
Now locate where you save the VBScript file. You should see the file like this.
Once found, double click on that file. A message box will show as how you set.
For your information, the button is not limited to “OK” button only. There are other Constants that you can try.
Constants | Value | Description |
---|---|---|
VBOKOnly | 0 | Show OK button |
VBOKCancel | 1 | Show OK and cancel buttons |
VBAbortRetryIgnore | 2 | Show abort, retry, ignore buttons |
VBYesNoCancel | 3 | Show yes, no cancel buttons |
VBYesNo | 4 | Show yes, no buttons |
VBRetryCancel | 5 | Show retry, cancel buttons |
VBCritical | 16 | Show critical message icon |
VBQuestion | 32 | Show warning query button |
VBExclamation | 48 | Show warning message icon |
VBInformation | 64 | Show information message icon |
VBDefaultButton1 | 0 | First button is default |
VBDefaultButton2 | 256 | Second button is default |
VBDefaultButton3 | 512 | Third button is default |
VBDefaultButton4 | 768 | Fourth button is default |
VBApplicationModal | 0 | Demands that the user respond to the dialog before allowing continuation of work in current application |
VBSystemModal | 4096 | Causes suspension of all applications until the user responds to the dialog |
Thanks for reading this article. Hopefully you find it helpful. Just a friendly reminder, all this guide is for education purpose. “GeekZag.com” will not responsible if anyone misuse information referred from this article and use it for bad intention.