hugas

how to make, that when user choose Yes on messageboxbuttons, then event form i want would appear


Re: Visual Basic Express Edition MessageBoxButtons.YesNo question

Jay_Vora_b4843e

system.windows.forms.form.messagebox.show(" ") returns an int value if its no it resturns 0 ,1 otherwise..

do like this

dim i as integer

i = msgbox code.

print i

u wil get all

hope u undrstnd






Re: Visual Basic Express Edition MessageBoxButtons.YesNo question

Tall Dude

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles Button1.Click

If MsgBox("Do you want to do this ", _

MsgBoxStyle.YesNoCancel) = MsgBoxResult.Yes Then

MsgBox("Yes was selected")

' Do yes code

Else

MsgBox("No or cancel selected")

' Do no code

End If

End Sub

End Class






Re: Visual Basic Express Edition MessageBoxButtons.YesNo question

Solitaire

Each of the MessageBox.Show buttons has a different return value so you can identify which one was clicked.

The DialogResult class includes: OK, Cancel, Abort, Retry, Ignore, Yes, No, None. It is used for responding to the return value of the MessageBox.Show() method.

You assign a variable to the MessageBox and use the System.Windows.Forms.DialogResult as the return value. You could also use the integer value of the DialogResult button, numbered from 1 to 8 in the same order as listed above.

Example:

ans = MessageBox.Show("Did you pass the test ", "Math Test", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

If ans = Windows.Forms.DialogResult.Yes Then 'or If ans = 6 Then
MessageBox.Show("Satisfactory")
End If






Re: Visual Basic Express Edition MessageBoxButtons.YesNo question

SJWhiteley

Solitaire has the gist of it. But do not use absolute numbers (also known as 'Magic Numbers') - use the DialogResult enumeration. The reason is that it makes code hard to read, debug and troubleshoot.