How to Create a Message Box?


Introduction: How to Create a Message Box?

In this instructable, you will learn how to create a message box with notepad on your computer. Below is an example of a message box.

Step 1: Open Up Notepad

Open up notepad on your computer. Type in the following:

x=msgbox ("yourtexthere" ,0, "yourtitlehere")

Replace 'yourtexthere' with the words you want in your message box and replace 'yourtitlehere' with the title you want on your message box (for example x=msgbox ("Do you want to learn how to make this message box?" ,4, "Instructables").

Step 2: Editing Your Message Box

To choose the types of buttons or how you want your message box to look like change the number in between the commas.

x=msgbox ("Example Text" ,your number here, "Example Title")

Replace your number here with one of the following:

0 displays the OK button only
1 displays the OK and Cancel buttons
2 displays the Abort, Retry and Ignore buttons
3 displays the Yes, No, Cancel buttons
4 displays the Yes and No buttons
5 displays the Retry and Cancel buttons
16 displays the Critical Message icon
32 displays the Warning Query icon
48 displays the Warning Message icon
64 displays the Information Message icon
4096 is a system modal; all applications are suspended until the user responds to the message box (in other words, this message box stays on top of all applications)

Below is how the boxes will look like.

Step 3: Saving Your Message Box

Click File and Save As... and save it as yourfilename.vbs. Replace 'yourfilename' with the file name you want (for example instructables.vbs). The .vbs must be left at the end otherwise your message box wont work. Save it somewhere on your computer.

Step 4: Testing Your Message Box

Open up the file you saved.

There you have it! A message box created by you.

Step 5: Some Tips

If you want you can put more message boxes on your file.
for example:
x=msgbox ("Do you want to learn how to make this message box?" ,4, "Instructables")
x=msgbox ("If you said yes go to the Instructables website" ,0, "Instructables")
x=msgbox ("If you said no close the message box" ,0, "Instructables")

If you want your message box to be uncloseable (when you click a button or the close button the message box will keep on reappearing) type this:

x=msgbox ("yourtexthere" ,0, "yourtitlehere")

The only way to stop this is to open up Windows Task Manager, go to the Processes tab and look for wscript.exe and click End Process.



  • Game Life Contest

    Game Life Contest
  • Water Contest

    Water Contest
  • Backpack Challenge

    Backpack Challenge

34 Discussions

Is there any way to make the PC shutdown or something to make it more scarier?



x=msgbox ("windows will not work becuse you smell" ,0, "TAKE A SHOWER")


Is there a GOTO equivalent in VBScript?

For instance, I want to make a prank virus, "SmartScreen" says "Do you want to delete?" Yes or No. If the user presses "no", it asks if sure, Yes or no. If yes, it goes back to the beginning as if the user pressed "yes" on the first dialog. If no the deletion cancels and the "virus" starts. But when on the "delete" route, it tries to delete, gives an error, says "Try again?" Retry or cancel. If cancel, the virus starts. If retry, it gives another error saying it "couldn't start an instance of SMRTSCRN.SYS", then the virus starts anyway.

I know that sound like a lot of stuff, but I just didn't want to put in the actual code.

been interested here! also, how to insert timer on gui? set gui "on" by 10 minutes and if no answer or reply, set default reply as "no". thanks a lot!

But I know how to make it more advanced(who can work with visual basic is in advantage):
First put on to the first line first (main) msessage box (that will decide what will happend next)
Then put this:

If x=vb* Then
x=messagebox("Second message box",any,"any")
End if

*Here you can put the name of the button that user was pressed (first letter must by big example: vbNo or vbIgnore...)

Here I create a cool example:

x=msgbox("Delete local disc D?",36,"Disc cleaner")
If x=vbNo Then
x=msgbox("Really no?",36,"Adjusting")
If x=vbNo then
x=msgbox("But you can't stop it.",64,"Status")
End if
End if
x=msgbox("Cleaning is starting.",64,"Disc cleaner")

And how it work's:
On start you have a "main" message saying: Delete local disc D?
On second line computer is checking what you was press and if it was No you see next message with question: Really no?
Then computer is again checking what you was press and if it was No you see message saing: But you can't stop it. and computer is going to last line
If it wasn't No then computer jump on the last line where is next message box saing: Cleaning is starting.
P.S. I think you can use this comment like next step :)

6 replies

Is there a way to make buttons that say custom things? For example, a message box that is yes or no, but says Always and Never.

How do you make it so that if you select yes for example it will do one thing but then if you press no it will do another thing?

Type this:

If x = vbNo Then

*User press No


***User doesn't press No - user press Yes or Ignore or OK or ...
End If

And if you want to react on more buttons (like when user can press Retry or Ignore or Abort) try this:

If x = vbRetry Then
ElseIf x = vbIgnore Then
ElseIf x = vbAbort Then
*Not Retry, not Ignore, not Abort - something else
End if


x=msgbox("You Have A Virus",0,"Virus")

Theres also another way follow ok


I tried 'x=msgbox ("All of your stuff toys have died due to underfeeding",4096,"Alert!")'. When I opened Internet Explorer, it is still showing it!

Oh, I get the 'system modal', example of it is like in Microsoft Office that you want to exit with unsave document and I tried to click some parts of the screen and it keeps beeping.

I have a code that can do something n times:

For i=1 to *

*number of times
**thing to do * times