Example MsgBox with a Prompt, yesNoCancel [Title]

I have tried over and over to put together a working Message box

Dim Prompt As String, Tilte As String, Status As String, Status2 As String
Dim Buttons As Integer

Prompt = "Welcome to Learning 5"
Title = "Unload File Check"
Status = "Was Unloaded"
Status2 = "File NOT Unloaded"
Buttons = vbOKOnly + vbCancel
MsgBox (Prompt)

I got this far, the Prompt shows the "Welcome to Learning 5"

Every time I tried adding second line of text with the & vbCrLf & Status got an error, I tried the "Status", I tried [Status]

If I just did (prompt + Status it worked but a mess, wanted two lines, plus I wanted the vbYesNoCancel buttons to pop-Up and I wanted a Title for the box

Anyway I called myself searching various ways

MsgBox Examples, Examples of MsgBox Function. Found a lot on Excel on-line but could not seem to make a working one for a starting point.

Jan gave me an example of Macro using variable and I was able to follow the working format on that. I keep looking for a working example

to learn from. Someone please help? No Will someone help me

This also was a failure MsgBox "Test Message Wanted" & CStr(This), vbOKOnly, + CrLf "Check"

Parents
  • Hi Richard,

    I Guess your Problem is the Word "Prompt", because it is a VBA Keyword, and so it is not allowed as variable name. That's why I use Pretext Notation.

    Sub DialogTest()
    
        Dim sPrompt As String, sTilte As String, sStatus As String, sStatus2 As String
        Dim nButtons As Integer
    
        sPrompt = "Welcome to Learning 5"
        sTitle = "Unload File Check"
        sStatus = "Was Unloaded"
        sStatus2 = "File NOT Unloaded"
        nButtons = vbOKOnly + vbCancel
        
        myPromt = sPrompt & vbNewLine & sStatus
        
       Dim myResult As VbMsgBoxResult
       
       myResult = MsgBox(myPromt, vbOKCancel, sTitle)
       
        
    End Sub
    

    Mit freundlichen Grüßen / Best regards
    Volker Hüfner

    |  AB_DATE Engineering  Software   |  ab-date.de  |

  • I read this information:

    VbMsgBoxResult Value Button Selected
    vbOK 1 OK ------------------------------ give a 1 when pressed
    vbCancel 2 Cancel ------------------------------ give a 2 when pressed
    vbAbort 3 Abort ------------------------------ give a 3 when pressed
    vbRetry 4 Retry ------------------------------ give a 4 when pressed
    vbIgnore 5 Ignore ------------------------------ give a 5 when pressed
    vbYes 6 Yes ------------------------------ give a 6 when pressed
    vbNo 7 No ------------------------------ give a 7 when pressed

    can you get something back from MsgBox to show or use the values ? Only wondering

    I did no see any on Critical, ok gotta go, thank you again.

    Version: MicroStation V8i SS 10

    RJB Phillips III (Richard) Praise the Lord for His Mercy and grace in Christ Jesus

Reply
  • I read this information:

    VbMsgBoxResult Value Button Selected
    vbOK 1 OK ------------------------------ give a 1 when pressed
    vbCancel 2 Cancel ------------------------------ give a 2 when pressed
    vbAbort 3 Abort ------------------------------ give a 3 when pressed
    vbRetry 4 Retry ------------------------------ give a 4 when pressed
    vbIgnore 5 Ignore ------------------------------ give a 5 when pressed
    vbYes 6 Yes ------------------------------ give a 6 when pressed
    vbNo 7 No ------------------------------ give a 7 when pressed

    can you get something back from MsgBox to show or use the values ? Only wondering

    I did no see any on Critical, ok gotta go, thank you again.

    Version: MicroStation V8i SS 10

    RJB Phillips III (Richard) Praise the Lord for His Mercy and grace in Christ Jesus

Children