Yes, No Dialog Boxes

tahu191

Well-known member
Joined
Oct 27, 2005
Messages
48
Location
USA
Programming Experience
Beginner
I need to know how to make a message box or something with a yes and now button. Also With an If...Then statement after it for if Yes is clicked or No is clicked. Thanks.
 
maybe a daft question, but i'm interested to know whats wrong with the message box that comes with vb.net?
But if i were to approach this problem i suppose it could be done as a seperate form in your application, you could add two buttons for the yes no and a label to display the information. Add some code behind to handle the click event of either button. Is this the answer you were looing for?:)
 
tahu probably does not know about messagebox. use:

MessageboxShow("MyMessage", "MyTitle", Features). I have a localized dll that creates messagebox with custom text on buttons. I can attach it if you are interested.
 
hey if u are developing Web application then just u have to do is write a javascript function - if(confirm("ur message")==true){do something return true;}else{do something return false;} and you are done.
 
tahu,

If MessageBox.Show("Message", "Caption", MessageBoxButtons.YesNo, MessageBoxIcon.____) = DialogResult.No Then
'do something or nothing
Else
'do something or nothing

I use it to confirm closing of my app when there is still an MDI Child open.

VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] frmMain_Closing([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], _
[/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.ComponentModel.CancelEventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Closing
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].MdiChildren.Length <> 0 [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] MessageBox.Show("Are you sure you want to exit? " & ControlChars.CrLf _
& "There is still form(s) open which may of not had changes saved", "Confirm exit", _
MessageBoxButtons.YesNo, MessageBoxIcon.Question) _
= DialogResult.No [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]e.Cancel = [/SIZE][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]

Hope it helps,
Luke
 
Back
Top