MessageBox using MessageBox API:   Return to List

Private Const MB_RETRYCANCEL = &H5&
Private Const MB_OKCANCEL = &H1&
Private Const MB_OK = &H0&
Private Const MB_ABORTRETRYIGNORE = &H2&
Private Const MB_YESNOCANCEL = &H3&
Private Const MB_YESNO = &H4&

Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal _
    hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType _
    As Long) As Long

Private Sub Form_Load()
    Dim rval As Long
    rval = MessageBox(Me.hwnd, "Hello.How r u?", "Test Message", MB_ABORTRETRYIGNORE)
    Select Case rval
        Case 1
            MsgBox "Ok button Pressed"
        Case 2
            MsgBox "Cancel button Pressed"
        Case 3
            MsgBox "Abort button Pressed"
        Case 4
            MsgBox "Retry button Pressed"
        Case 5
            MsgBox "Ignore button Pressed"
        Case 6
            MsgBox "Yes button Pressed"
        Case 7
            MsgBox "No button Pressed"
    End Select
    End
End Sub



Note to Webmaster