Understanding the MsgBox command in Visual Basic

Level:
Level1

This VB6 tutorial explains how to use the MsgBox function in Visual Basic. This also works for VBS MsgBox. The MsgBox function displays a message in a dialog box, waits for the user to click a button, and returns an Integer indicating which button the user clicked.

 

Syntax:

MsgBox(prompt[, buttons] [, title] [, helpfile, context])

 

The MsgBox function syntax has these parts:

 

Part

Description

prompt

Required. String expression displayed as the message in the dialog box. The maximum length of prompt is approximately 1024 characters, depending on the width of the characters used.

buttons

Optional. Numeric expression that is the sum of values specifying the number and type of buttons to display, the icon style to use, the identity of the default button, and the modality of the message box. If omitted, the default value for buttons is 0 (which causes only an OK button to be displayed with no icon). The buttons argument is explained in more detail below.

title

Optional. String expression displayed in the title bar of the dialog box. If you omit title, the application name is placed in the title bar.

helpfile and context

Both optional. These arguments are only applicable when a Help file has been set up to work with the application.

 

The buttons argument

The first group of values (0–5) describes the number and type of buttons displayed in the dialog box; the second group (16, 32, 48, 64) describes the icon style; the third group (0, 256, 512, 768) determines which button is the default; and the fourth group (0, 4096) determines the modality of the message box. When adding numbers to create a final value for the buttons argument, use only one number from each group.

 

First Group - Determines which buttons to display:

 

Constant

Value

Description

vbOKOnly

0

Display OK button only.

vbOKCancel

1

Display OK and Cancel buttons.

vbAbortRetryIgnore

2

Display Abort, Retry, and Ignore buttons.

vbYesNoCancel

3

Display Yes, No, and Cancel buttons.

vbYesNo

4

Display Yes and No buttons.

vbRetryCancel

5

Display Retry and Cancel buttons.

 

Second Group - Determines which icon to display:

 

Constant

Value

Description

Icon

vbCritical

16

Display Critical Message icon.

vbQuestion

32

Display Warning Query (question mark) icon.

vbExclamation

48

Display Warning Message icon.

vbInformation

64

Display Information Message icon.

 

Third Group - Determines which button is the default:

 

Constant

Value

Description

vbDefaultButton1

0

First button is default.

vbDefaultButton2

256

Second button is default.

vbDefaultButton3

512

Third button is default.

vbDefaultButton4

768

Fourth button is default (applicable only if a Help button has been added).

 

Fourth Group Determines the modality of the message box. Note – generally, you would not need to use a constant from this group, as you would want to use the default (application modal). If you specified "system modal", you would be "hogging" Windows – i.e., if a user had another app open, like Word or Excel, they would not be able to get back to it until they responded to your app's message box.

 

Constant

Value

Description

vbApplicationModal

0

Application modal; the user must respond to the message box before continuing work in the current application.

vbSystemModal

4096

System modal; all applications are suspended until the user responds to the message box.

 

There is a fifth group of constants that can be used for the buttons argument which would only be used under special circumstances:

 

Constant

Value

Description

vbMsgBoxHelpButton

16384

Adds Help button to the message box

VbMsgBoxSetForeground

65536

Specifies the message box window as the foreground window

vbMsgBoxRight

524288

Text is right aligned

vbMsgBoxRtlReading

1048576

Specifies text should appear as right-to-left reading on Hebrew and Arabic systems

 

When you use MsgBox to with the option to display more than one button (i.e., from the first group, anything other than "vbOKOnly"), you can test which button the user clicked by comparing the return value of the Msgbox function with one of these values:

 

Constant

Value

Description

vbOK

1

The OK button was pressed

vbCancel

2

The Cancel button was pressed

vbAbort

3

The Abort button was pressed

vbRetry

4

The Retry button was pressed

vbIgnore

5

The Ignore button was pressed

vbYes

6

The Yes button was pressed

vbNo

7

The No button was pressed

Note: To try any of the MsgBox examples, you can simply start a new project, double-click on the form, and place the code in the Form_Load event.

 

There are two basic ways to use MsgBox, depending on whether or not you need to know which button the user clicked.

 

·         If you do NOT need to test which button the user clicked (i.e., you displayed a message box with only an OK button), then you can use MsgBox as if you were calling a Sub. You can use the following syntax:

 

Msgbox arguments

-or-

Call MsgBox(arguments)

 

Examples:

 

o        The statement

 

MsgBox "Hello there!"

causes the following box to be displayed:

 

 

This is the simplest use of MsgBox: it uses only the required prompt argument. Since the buttons argument was omitted, the default (OK button with no icons) was used; and since the title argument was omitted, the default title (the project name) was displayed in the title bar.

 

o        The statement

 

MsgBox "The Last Name field must not be blank.", _

vbExclamation, _

"Last Name"

causes the following box to be displayed:

 

 

This is how a data entry error might be displayed. Note that vbExclamation was specified for the buttons argument to specify what icon should be displayed – the fact that we did not add a value from the first group still causes only the OK button to be displayed. If you wanted to explicitly indicate that only the OK button should be displayed along with the exclamation icon, you could have coded the second argument as

 

vbExclamation + vbOKOnly

making the full statement read:

 

MsgBox "The Last Name field must not be blank.", _

vbExclamation + vbOKOnly, _

"Last Name"

 

Remember, for the buttons argument, you can add one value from each of the four groups.

 

An alternative (not recommended) is to use the hard-coded number for the buttons argument, as in:

 

MsgBox "The Last Name field must not be blank.", 48, "Last Name"

 

Note also that this example provided a value for the title argument ("Last Name"), which causes that text to be displayed in the box's title bar.

 

The format of the MsgBox statement used in this example could also be used for more critical errors (such as a database problem) by using the vbCritical icon. You may also want to use the name of the Sub or Function in which the error occurred for your title argument.

 

Example:

 

MsgBox "A bad database error has occurred.", _

vbCritical, _

"UpdateCustomerTable"

 

Result:

 

 

·         If you DO need to test which button the user clicked (i.e., you displayed a message box with more than one button), then you must use MsgBox as a function, using the following syntax:

 

IntegerVariable = Msgbox (arguments)

 

One of the more common uses of MsgBox is to ask a Yes/No question of the user and perform processing based on their response, as in the following example:

 

Dim intResponse As Integer

 

intResponse = MsgBox("Are you sure you want to quit?", _

vbYesNo + vbQuestion, _

"Quit")

 

If intResponse = vbYes Then

End

End If

 

The following message box would be displayed:

 

 

After the user clicks a button, you would test the return variable (intResponse) for a value of vbYes or vbNo (6 or 7).

 

Note that the use of the built-in constants makes the code more readable. The statement

 

intResponse = MsgBox("Are you sure you want to quit?", _

vbYesNo + vbQuestion, _

"Quit")

is more readable than

 

intResponse = MsgBox("Are you sure you want to quit?", 36, "Quit")

and

 

If intResponse = vbYes Then

 

is more readable than

 

If intResponse = 6 Then

 

 

In that you can use a function anywhere a variable can be used, you could use the MsgBox function directly in an if statement without using a separate variable to hold the result ("intResponse" in this case). For example, the above example could have been coded as:

 

If MsgBox("Are you sure you want to quit?", _

vbYesNo + vbQuestion, _

"Quit")= vbYes Then

End

End If

 

 

Note: If desired you could place the code for this example in the cmdExit_Click event of any of the "Try It" projects.

 

Following is an example using the vbDefaultButton2 constant:

 

Dim intResponse As Integer

 

intResponse = MsgBox("Are you sure you want to delete all of the rows " _

& "in the Customer table?", _

vbYesNo + vbQuestion + vbDefaultButton2, _

"Delete")

 

If intResponse = vbYes Then

' delete the rows ...

End If

 

The message box displayed by this example would look like this:

 

 

 

The sample project for this topic contains a command button for each MsgBox example given above.

 

VBS MsgBox note

Visual Basic Script (VBS) also supports this same MsgBox function. Feel free to make use of this code in any VBS related code.

 

Download the VB project code for the example above here.

Originally Written By TheVBProgramer.

$ReqTestHarness$

If you enjoyed this post, subscribe for updates (it's free)

vb6

i just want to implement when i move a mouse on save command button it should display save when i move a pointer on it tht sol pls help me in this

VB6 how to enlarge & shrink a Label caption in command buttons?

May I know how to enlarge a Label Caption in a command button? Follow by second command button to shrink the Label Caption.

comboBox linking another form

Hi.. I want help that when I clicked an items in ComboBox it will link to another form..

thanks..:D

Reply to comment (VB6)

Theѕe are reаlly great ideas in abοut blogging.
Yоu have touchеd some nice thіngѕ here.
Any waу keеp up wrinting.

VB2005

hi please help me ..
i just want to know how to add constant values to a button and appear the number/value in textbox..?? when i click the button. thanks in advance :)

HowTo force to loose focus for textbox and help form to get it

When I have a Form and some textbox I Had this problem...
When any of them textbox set focus it was really a problem that the form set focus again
Im doing this thing, and my form_main can set focus

Private Sub Form_Click()
Text1.locked = true
End Sub

And when I'm clicking on any textbox...

Private Sub Text1_Click(Index As Integer)
Text1.locked = false
End Sub

Where i can get the program from

Hey is there any Free download as i am 17 years old and dont have enouph money in paypal to afford maybe buying this so please maybe send me a link for that Download thank you

VB

..HELU.. HOW CAN I DISPLAY THE MASSAGE BOX.?

Reply

'Show a Question message box to comfirm if the User wants to close the Form. Place this in the Form_QueryUnload event
'Run the Program and try closing the Form
IF MsgBox ("Are you sure you want to close this Form?", vbQuestion+vbYesNo+vbDefaultButton2, App.Title) = vbNo THEN
       Cancel = True
END IF

How can I make a command run

How can I make a command run as soon as you press a button in a message box?

Like....I want the computer to shut down as soon as I click OK in the message box and it disappears.

Try like, set objShell =

Try like,
set objShell = CreateObject("WScript.Shell")
x=2
while x=2
x = MsgBox("Shutdown computer?", 3,"System")
wend
objShell.sendkeys "shutdown -s{enter}"

you have to add the if

you have to add the if command to the end so,
If x = 6 Then
objShell.sendkeys "shutdown -s{enter}"
End If

Modify on menuscript

I need the code for modify!when i change the spelling of the person's name on the text boxes and click on modify the name must be modified and appear in the listbox

i want message box in bottom of the form

how to display messagebox in a required place(not default place i.e. center) in a form....pl give information....i want message box in bottom of the form

regards
brahmam

adding new constant in vb

I want to add new constant in vb Eg. vbyes,vbno,vbok like this suppose i want to add vbopen,vbclose,vbrest.

How can I change the font size of the MsgBox

How can I increase the font size of MsgBox.

visual basic

The explosive growth of Internet communications and data storage on Internet-connected computers has greatly increased privacy concerns. The field of cryptography is concerned with coding data to make it difficult (and hopefully – with the most advanced schemes-impossible) for unauthorized users to read. In this exercise, you’ll investigate a simple scheme for encrypting and decrypting data. A company that wants to send data over the Internet has asked you to write a program that will encrypt it so that it may be transmitted more securely. All the data is transmitted as four-digit integers. You application should read a four digit integer entered by the user and encrypt as follows: replace each digit with the result of adding 7 to the digit and getting remainder after dividing the new value by 10. Then swap the first digit with the third, and swap the second digit with the fourth. Then display the encrypted integer.
help me do this questions

GPF on MsgBox Call

I'm hoping someone can give me some sage advice, because I'm completely stuck. I recently upgraded from SP5 to SP6 and ever since, my VB6 project GPF's in design-time whenever the code hits a MsgBox() event ... any MsgBox() event! These have always worked just fine up to now. Ugh! :-(

how to insert a value from

how to insert a value from input box into msg box?

User_name=InputBox("Press

User_name=InputBox("Press user name")
MsgBox "User "& User_name &" is OK"

visual basic6.0 comands

hello,sir it is nice web site,i study from this site and i satisfied to the site.
if u can than please mail me total visual basic 6.0 co-mads.

vbmsgboxhelp inquiry

How can I put an event for the help button if my message box is msgboxhelpbutton.
I would just like to show a form for help button. Thank you.

I enjoyed this data and look

I enjoyed this data and look forward to being able to use it in the near future

need help!!

how to call the declared variable in input box to join it in the msg box..
to understand it better i have here my code:

Dim name As String
name = InputBox("Enter your full name:", "Input Name")

and i need to have a msgbox, wherein i need to insert the name (the one that's declared)

i can you give me a sample code?..i really need it..

thanks!!

can i ask question how to

can i ask question how to delete in visual basic when its is connected in visual basic

many inputbox

Dear all,

I have one query about inputbox,
I have input box while clicking vbsOk it's not showing input value in msgbox else clicking on vbsCANCEL my msgbox of Cancel is proper.

Can you clear my Query.

Thanks.

help me..

can someone tell the function of

"Dim intResponse as integer"

in the code?

what will happen if it is added?

tis the value returned by

tis the value returned by the message box function, so when it returns the value you have it declared so that the system is aware of the data type being returned, you could probably use: Cint(value) =

But that's just the way I read it, typecasting is a really useful tool to use.

vb

the code
"dim intresponse as integer"
keeps account of which button u hav chosen in a msgbox that contains more than one button..
for example.. in a msgbox with button YES\NO.. the responses we use to write is vbYES=true or vbNO=true.. but each of these responses hav an integer value.. to store this values we use the above code....

Pretty easy.

That's just declaring a variable(in which you will store something) as an Integer data type, you will most likely do something like intResponse = CInt(txtA.Text).

This will make you able to

This will make you able to control a new variable, so you can use its value in later commands,
Moreover, this variable mentioned is an integer, which can accept a number only, so if you try to assign a text to it, it wont accept it.
I suggest you read more about Variables in Visual Basic.
Good Night,

Is it possible to put math into the message text?

For example, I want to write in MsgBox(10*50 + "years ago.", _..., _)

Yes you can

Try MsgBox 20*50 & " years ago..."

vb message box button

i want to modify the name my my buttons in msgbox()
anyone can send here codes

i Think you need an InputBox

i Think you need an InputBox not A message box, read more about input box.

hi i am creating a program

hi i am creating a program in vb.net which display decimal, octal, hexadecimal, binary in textbox...i was hopeing if someone can give me a start

in vb.net plz

in vb.net plz

msgbox blocker

how to block msgbox using check box.
example: if i click the command button then a msgbox will appear if i checked the checke box,when i click the command button no msgbox will appear.
what code will i use to have this result? thank you for answering xD

how to block msgbox using check box

commandbutton1.click()
if checkbox1.value = true then
call process
end if
end sub

sub process ()
Dim i
i = MsgBox("Do you want to end this program?", vbYesNo + vbQuestion, "END PROGRAM?")
If i = vbYes Then

End
Else
CommandButton1.BackColor = QBColor(3)
End If

End Sub

fastest way to learn vb code...

Thanks for this tutorial - I'm especially glad it works with vbs msgbox as well. Does anyone know the fastest way to learn vb like ..any book or somthing....thanks

first u know about

first u know about all tool bar aptions and project properties and events used in vb

Encrypton

I need a code user only allowed to enter four-digit integer in textbox .: Replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by then swap the first digit with the third and swap the second digit with the fourth.
Thks

dividing new value by 10.

dividing new value by 10. plz some help me ,, i really need the code thks lot

An easier script

An easier script is:
lol=msgbox ("Insert Message Here",49,"Insert Title Here")
I only make message boxes with vbs and notepad.
For lua you would say:
print "Message"
Very simple scripting techniques for all people! And
--Message
Just makes it not show anything with the --

URGENT HELP

Can you guys give me the code for when I have a box for users to insert their name, then they click a button, then they get a personalised message with their name in it? thanks! Just code please, im dumb

olivera can you give me a

olivera

can you give me a clear question

olivera

olivera

can i ask you some question??...

can you give some codes in vb6 in arrays??

txtbox or button

ma'am and sir.....

can i ask a question??.... im just new in VB6... about 2 months...

how can you call msgbox using txtbox or commandbutton

for example:
the txtbox is empty... if i type in the word "kevin" the msgbox will come up with out clicking or doing anything ..
and
how can i call msgbox using command button...example if type the word "kevin" and click the button... the msgbox will come up

just give me the codes sir... or if want fer me to get it easily give me some explanation hehehe

thnks!!

How to Clear the Input msg. in the TxtBox? pLz do answer me!

..i am a begginer in Visual basic..could u help me how to clear the input message in the txtbox? just a simple code but i dont know how..pls reply urgently because i badly needed it..thank u Guys.

wish this help you

just put and empty string on the beginning of the program...

example

private sub command1_click

textbox = ""

end sub

Note: This works for vbs MsgBox as well.

just put an empty

just put an empty string

e.g:

textboxname.text = " "

:

how to connect vb6, access and crystal report
pls send me some example

Message boxes and Queries - as series of them

I am trying to achieve the following:-
message box that asks do they want to proceed - YEs/Cancel required
If yes, open another messagebox which tells them what they are about to do
then run an update query
when done, open another messagebox which tells them what they are now about to do
then run a second update query
when done, open another messagebox which tells them the updates have been successful.

I can do almost all of it with a macro, but it won't let me to have that first Yes/Cancel.

I cannot work out how to do it in a module.

And of course, I want to get rid of those meaningless message boxes that Access pumps out, which simply frighten my users

Any advice would be appreciated

Sub PowerData1() a =

Sub PowerData1()
a = MsgBox "Total Power Generated " , 32 + vbQuestion + vbOk + vbSystemModal, "")
If a = vbOKThen End
End Sub

In the Message box above I want to Underline Total Power Generated .How could I do that

Open a file.

When I made this message box,

Dim intResponse As Integer

intResponse = MsgBox("Your Pc has found a virus," & Chr(13) & "would you like to remove it?",4+48,"Windows 7")

If intResponse = 6 Then

If its 6 I want it to open a file on my computer and if 7 open a different file? How do I do that?

Please tell me!!!!!!!!!!!!

Message with NO buttons?

I want to put a message onscreen while my Excel module does some processing, something like "Please wait..."

... then clear it automatically when the process is finished.

I don't want my user to have to click any buttons; I just want to tell them something's happening.

Is this possible?

Phil

sugestion

you can create a form and put in a progress bar,
your form will be your "msgbox" , do you unsderstand ?

Instead of using a MsgBox,

Instead of using a MsgBox, why don't you create a small form with the message in a text box, show the form when you start your process, then hide it when the process has finished.

You could pass various messages to the TextBox so it changes as your process does different things (eg. Gathering Data, Calculating Results, Preparing Report) just so that the user knows that something is happening and it hasn't got stuck.

I tend to use the Status Bar instead of a form, but the principle is the same.

Let me know if you need guidance on how to do this.

Ben

message boxes

umm... im really bored and i wanna make a program where there is one button and when you click it, message boxes appear all over the screen... kinda like a spam thing... yea i want to know how to do that...

dim i as double i=0 do while

dim i as double

i=0

do while i =0
msgbox "TAMAD KA!"
next i

vpaf

LOL

haha ayos pare Tamad talaga siya go pinoy programmers!!!

thanks for the info... saved

thanks for the info... saved me some major headaches!

Display Message box for couple seconds only

How I can display Message box for couple seconds and then closed automatically.
Thanks for your help

random phrase

I can make it return a random number between one and one hundred:
Randomize()
randomNumber=Int(100 * Rnd())
document.write"A random number:"&randomNumber&""
But how do I make it return a random phrase?
PLEASE HELP ME!!!

Simple

Dim randnumber As Integer
 
Randomize
randnumber = Int(6 * Rnd())
Select Case randnumber
    Case 1
        MsgBox "Some random phrase"
    Case 2
        MsgBox "A different phrase chosen at random"
    Case 3
        MsgBox "A random sentence"
    Case 4
        MsgBox "Randomly picked phrases are fun"
    Case 5
        MsgBox "This was chosen at random"
    Case Else
        MsgBox "Something else!"
End Select

how can control checkbox?

i cannot use the button clear to clear the check box..please help me with the note of using check book and loop..

Clear CheckBox

It's very simple!
Just add this:

CheckBox1.Checked = false

If you want to add a condition:

If CheckBox1.checked = true Then
      MsgBox("CheckBox1 is checked!")
Else
      MsgBox("CheckBox1 isn't checked!")
End If

Thanks

multiline msgbox?

how can i create 2 lines or multiple lines in msgbox??

sugestion

Read about VBNEWLINE

fonts in msgbox

hi

I just want to display a msg in msgbox but font should be in hindi
plz tell me how to do it.

richa

"how to use font in msgbox" Please send source code

Dear,

Please send source code in use msgbox font

Thanking you,

Rajesh Gund
9552224464

when we put 2 text boxes and

when we put 2 text boxes and a command button .... nd we want that which value greater comes in a msgbox ..... what's the coding ??

to find which value is greater

do the following

Dim n1, n2 As Integer
n1 = Val(Text1.Text)
n2 = Val(Text2.Text)
If n1 > n2 Then
Print " greater value is " & n1
Else
Print "greater value is " & n2
End If

for further information contact me @
ntfbrothers@gmail.com

How do I make "yes" or "no" say something else?

I'm trying to make it so.. either my touch screen or voice recognition software only needs to have me say "Hello" in place of next.. so that I can just be like hello and suffice that as an, "Ok" or "yes"? rob my e-mail off this if someone can explain.. thanks

Math

Private Sub Command1_Click()
Dim num1 As Double, num2 As Double
'Convert the textbox to an integer, incase they put in letters
num1 = Val(Text1.Text)
num2 = Val(Text2.Text)
If (num1 > num2) Then
    MsgBox num1
Else
    MsgBox num2
End If
End Sub

how to create a log in form using VB 6.0?

hello...i am conscious on how to make a simple log in form in VB 6.0 in which the username and password are already inialized with the codes,if the username &username textbox meet the correct given codes then continue,and if does not msgBox right?...now how can i create a codes for my program that will initialized the username and password..please help me sir for my school project...thanks.just send me if i dont reply...thanks have a nice day

how to program msgbox in two lines

how to program a two lines-Msgbox with vb

mean : if you have a textbox to enter your name
and a message box to enter your birthdate

what is the code to a button that show your name in first line and your birthday in a secondline

Multiple line output in MsgBox

To get multiple lines output in MsgBox, use chr(13) in display string.

For exmple: msgbox "Record already exists." & chr(13) & "Do u want to replace?", vbYesNo, "Overwrite"
The output will look like:

Record already exists.
Do u want to replace?

how to link a form to

how to link a form to vbMsgBoxHelpButton

how do u include an option

how do u include an option button in the prompt?

Thank's to your guide...

Thank's to your guide... it's good.. . . . I learn LOTS OF COMMAND in here...Please do a Program that will go to previous form when the password is not accepted for 4 consecutive trial's.....

msg box

wow thank you guys.........your code is easy to understand so i learn a lot thank you for this site

msgbox

how do i make msg to generate over 4 of the common MessageBox Button types (ex. Ok, Abort-Retry-Ignore, Retry-Cancel, etc.)

and how to make an option to change the MessageBox Icons; the warning sign, information, and so on

thanks

How to delete records in a recoedset( vb with oracle)

how to make EXE file in vb project

vb

how i can give a msgbox in visual basic when i am enter a alphabet in place of number in text box
i want a msgbox like "enter the numeric value"

Private Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim s
s = 0
If KeyAscii >= 48 And KeyAscii <= 57 Then 'This one for Numeric value Checking
s = 1
Else
If KeyAscii = 32 Or KeyAscii = 8 Then 'This one for BackSpace and Space Button Checking
s = 1
Else
s = 0
End If
End If
If s = 0 Then
MsgBox "Enter the Numeric Value", vbExclamation
End If
End Sub

Question

How I can change font size in MsgBox?
Thank, Nikola

reply

tht thank you brother
if you can to help me
i have assignments
:" write program to convert the text of the textbox to bold, Italic, Underline by making use of Checkboxs.

Visual Basic

When i used to add title or command buttons, i got syntax error. From this site, i got clear statements how to write in msgbox .

Prompt box for Deleting rows in a grid view

Hi i am creatin a grid with the edited feilds edit and delete, i want to know how i can make a prompt box when users click on the delete button, at the moment when i click delete it automaticaly deletes the record without any prompting, and its not a button its a link in the grid view. do i use this code below? if so do i need to create a button? if not then how do i go by doing this, pleaseeee hellp :(

Dim intResponse As Integer

intResponse = MsgBox("Are you sure you want to delete all of the rows " _

& "in the Customer table?", _

vbYesNo + vbQuestion + vbDefaultButton2, _

"Delete")

If intResponse = vbYes Then

' delete the rows ...

Elseif intResponse = vbno Then

'form1.show

End If

VB Message Box

I'm the msg box, i want it to show both text and to follow a command.
But each time i try this an error occurs where i need one or no brackets surrounding it.

So far i have been trying this,

Private Sub mnufilegamegivemenumber_Click()
MsgBox (random_number)
"The number must be between 1 and 100"
End Sub

But it's not working, can you think of any solutions?

Try This

Learn the vb constant "vbCrLf", and make use of it :D it's veryyy useful.

]
Private Sub mnufilegamegivemenumber_Click()
    Call MsgBox (random_number & vbCrLf & "The number must be between 1 and 100")
End Sub

vb6 programming

hi!! i analized yours examples and it is not easy to remind all the words in using coding, but i realize everytime i red it it comes to my mind that it is wonderful when making a codes as will i likely to see in your example. thanks !!!!!!! (:

Answer from Sweden

look its easy...
You just create an text-document and then push the button [Save as...], there you type your name on the file and the last thing MUST be .vbs if it gonna work.
(your name here).vbs
ah, yes. write: MsgBox "Hello there!"
in the text ducoment to get a msgbox like the writers example.

WOW - Thanks for the

WOW - Thanks for the examples - that's what I call a real learning tool!!!!! THANK YOU!! 17Nov2008

text in a msgbox?

its not msgbox. its another feature of vb 6, it is input boxes,

example

inputbox "prompt,default"

text in a msgbox?

its not msgbox. its another feature of vb 6, it is input boxes,

example

inputbox "prompt,default"

thanks,

thanks.this article is very useful to me

wat if

wat if i click no how to do the code that will let the form come back to normal because "quit is End right wat if i click No so the form will show up again..

Dim intResponse As

Dim intResponse As Integer

intResponse = MsgBox("Are you sure you want to delete all of the rows " _

& "in the Customer table?", _

vbYesNo + vbQuestion + vbDefaultButton2, _

"Delete")

If intResponse = vbYes Then

' delete the rows ...

Elseif intResponse = vbno Then

'form1.show

End If

Dim intResponse As

Dim intResponse As Integer

intResponse = MsgBox("Are you sure you want to delete all of the rows " _

& "in the Customer table?", _

vbYesNo + vbQuestion + vbDefaultButton2, _

"Delete")

If intResponse = vbYes Then

' delete the rows ...

Elseif intResponse = vbYes Then

'form1.show

End If

help...

how do you make a text box inside the msgbox?

Input Box

It is not a txtbox in a msg box. It is a input box.
ans=InputBox("What is your name?")

The above code vil display an input box , where u can enter ur name, n ur name vil b stored in de variable ans.

to include text box in msg box

use de input box function

It is not a txtbox in a msg

It is not a txtbox in a msg box. It is a input box.
ans=InputBox("What is your name?")

The above code vil display an input box , where u can enter ur name, n ur name vil b stored in de variable ans.

how to design our own title bars and message boxes

Hellooo..
Im a beginer with vb i have been done some simple projects but now i need design title bars and meesage boxes in my own style plz.. help me if u know about this

Custom Forms

This could be pretty advanced for somebody who is fairly new to doing simple projects in VB.
What you could do, though, is, as the person above suggested, make new forms.
Create a new form (call it, say, frmMsgBox), set the border style of your own custom messagebox to 0 - none, and just put a picture in the background that you've made in paint/photoshop/etc. to use as your own "message box design", and place buttons on it aswell.
Then, to load it up like a message, instead of calling MsgBox, you could do:

frmMsgBox.Show vbModal

The vb constant vbModal will make your new form act like a messagebox would. The user would no longer be able to interact with the parent form until the modal form (frmMsgBox in this case) is closed.

Easy

Make a new form.

some work on vb express 2008

some work on vb express 2008

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.