DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   Dialog Box (http://www.daniweb.com/forums/thread117630.html)

mansi sharma Apr 5th, 2008 3:44 pm
Dialog Box
 
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.

techtix Apr 5th, 2008 4:44 pm
Re: Dialog Box
 
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/lib...82(VS.60).aspx

Jx_Man Apr 5th, 2008 11:14 pm
Re: Dialog Box
 
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.

sonia sardana Apr 5th, 2008 11:16 pm
Re: Dialog Box
 
.

techtix Apr 5th, 2008 11:45 pm
Re: Dialog Box
 
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("Have a gala shopping", vbOKCancel + vbInformation + vbDefaultButton1, "welcome to the superMarket")

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

End Sub

mansi sharma Apr 5th, 2008 11:45 pm
Re: Dialog Box
 
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...

techtix Apr 5th, 2008 11:50 pm
Re: Dialog Box
 
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.


All times are GMT -4. The time now is 10:33 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC