I am creating a message box in VB8 for an error. I created the message box and everything works. The message box returns a value of 0 which is the default one. Where does it return 0 to. Or do you have to tell it where to return it.

A messagebox should not be returning a value of zero. It is better to use the DialogResult constants to see what the values mean but again either way none of these values should be zero. Even clicking on the X button in the top right corner would return a default value.

Dialog Returned Values:
OK : 1
Cancel : 2
Abort : 3
Retry : 4
Ignore : 5
Yes : 6
No : 7

Private Sub Button1_Click(...) Handles Button1.Click

        Dim dlgResult As DialogResult = Nothing

        dlgResult = MessageBox.Show("Do you want to continue?" _
                                    , "Msg Caption" _
                                    , MessageBoxButtons.YesNoCancel _
                                    , MessageBoxIcon.Question)

        'Display selected values from previous messagebox
        MessageBox.Show(String.Format( _
                        "dlgResult String Value : {0}{1}" & _
                        "dlgResult Numeric Value: {2}" _
                        , dlgResult.ToString _
                        , ControlChars.NewLine _
                        , CInt(dlgResult)))

End Sub

If you need anymore help just let me know.

Edited 7 Years Ago by TomW: n/a

I am creating a message box in VB8 for an error. I created the message box and everything works. The message box returns a value of 0 which is the default one. Where does it return 0 to. Or do you have to tell it where to return it.

try this....
Dim msg As String
Dim msgResult As MsgBoxResult
msg = "IF YOU WANT THIS FILE AS DEDUCTIBLE THEN CLICK OK.... TO LEAVE AS IS CLICK CANCEL" & Chr(13)
msg &= "Click OK to MARK DEDUCTIBLE, or CLICK CANCEL TO NOT MARK"
msgResult = MsgBox(msg, MsgBoxStyle.OkCancel, "MARK FILE AS DEDUCTIBLE")
If msgResult = MsgBoxResult.Cancel Then
GoTo OVER
Else
CK.Category = Mid(CK.Category, 1, 5) + "*" + Mid(CK.Category, 6, Len(CK.Category))
ListBox1.Items.Add(NEM + " " + CATG)
FilePut(2, CK, CINC)
End If
LOOP

GoTo OVER

' rem phill

This question has already been answered. Start a new discussion instead.