I don't know what keyword to search.
This is on a module in my app.
Public Sub msgYNC(ByVal result As DialogResult)
result = MessageBox.Show("Are you sure you want to save and continue?", "RM Farms Confirmation", _
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
End Sub
Now I want to use it on a form. So when I click on Confirm :
Dim result As DialogResult
msgYNC(result)
If result = Windows.Forms.DialogResult.Yes Then
'yes
ElseIf result = Windows.Forms.DialogResult.No Then
'n
ElseIf result = Windows.Forms.DialogResult.Cancel Then
'ca
End If
But it doesn't return me anything.. I don't get a response. I am not sure how to code this, can you pinpoint what's wrong?
The solution should be quite simple. Don't use byval in your Sub, use byref
Public Sub msgYNC(ByRef result As DialogResult)
result = MessageBox.Show("Are you sure you want to save and continue?",
"RM Farms Confirmation", _
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
End Sub
could you try this?
Altough you could use the following structure (if you only want to show a messagebox in your sub-method msgYNC
)
Select Case MessageBox.Show("", "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
Case Windows.Forms.DialogResult.Yes
'Do something
Case Windows.Forms.DialogResult.No
'Do something else
Case Windows.Forms.DialogResult.Cancel
'Cancel something
Case Else
'Do something unusefull
End Select