Private Sub Command2_Click()
MsgBox "Have a gala shopping", vbOKCancel, "welcome to the superMarket"
End Sub

Hey, 1) I want to know how to add icons in the message Box .
2) How To Set the Default Button.

MsgBox is a function with a return parameter available. The syntax is as follows: ReturnVal = MsgBox(Prompt, Options, Title) Options is a combination of your buttons, icons, and default button.

Example: ReturnVal = MsgBox("Do you want to continue?", VBYesNo + VBQuestion + VBDefaultButton1, "Closing") The allowable values are listed on the Microsoft MSDN Library web site
http://msdn2.microsoft.com/en-us/library/aa445082(VS.60).aspx

to set default button u don't have to fill button style in msgbox or use vbdefaultbutton style.
ex : msgbox("message","Titile") -> it will shown Ok only.
to get other icon do like techtix said.

When calling a function, make sure you use parentheses. Also, you are not soliciting a vbYes from the user. Just a vbOK or vbCancel.

** It's a personal preference, but when I call a function that is overloaded as a method, I try to always still call it as a function.

Private Sub Command2_Click()
Dim iResponse As Integer

iResponse = MsgBox[B]([/B]"Have a gala shopping", vbOKCancel + vbInformation + vbDefaultButton1, "welcome to the superMarket"[B])[/B]

If iResponse = vbOK Then
     Call MsgBox("sonia")
End If

End Sub

Private Sub Command2_Click()
Dim response As Integer

Response=MsgBox "Have a gala shopping", vbOKCancel + vbInformation + vbDefaultButton1, "welcome to the superMarket"

If response = vbYes Then
MsgBox "mansi"
End If
End Sub

I want to display the further msg on Yes button ,But the error is the response.

Jx_man,Ya dats right,by default first button in the dialog Box is the default button, But if there are two buttons, & to set the second button as default button, we have to follow the texttix code...

Still a problem here. The MsgBox options you are setting are vbOkCancel. This will never return a vbYes. Your only options for a return code are vbOk and vbCancel.

** See my previous post for the correct code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.