• MsgBox Return Value

    Author
    Topic
    #356276

    Hi all,

    I seem to be having some difficulty gathering the return value for the vbMsgBoxHelpButton. I have put the help button into the msgbox code, but the msgbox argument doesn’t seem to return the correct number. Here is my code:

    Public Sub Check()
    Dim i As Integer, pbr As Integer
    i = 0
    For Each cell In Sheets("Salesrecord").Range("d12:ap12")
        If cell.Value = "Incomplete" Then i = i + 1
    Next
    If i >= 0 Then pbr = MsgBox("You have " & i & " day(s) which have not been completed", vbOKOnly + vbMsgBoxHelpButton)
    If pbr = 16384 Then HelpClose.Show
    End Sub

    I have tried to evaluate pbr as 16383, 16384, 16385, and as vbMsgBoxHelpButton but when I run to the cursor, pbr always seems to equal 1. Any ideas as to the error in my code or syntax?

    Thanks,

    Viewing 0 reply threads
    Author
    Replies
    • #527024

      Mike,

      From what info I can find on vbMsgBoxHelpButton, it doesn’t work in the way you’re wanting it to work – that is, to show a userform when the user clicks on that button.

      In order to use vbMsgBoxHelpButton, you need to include helpfile and context arguments into the MsgBox function statement. The helpfile argument specifies the Help file you want to display; this must be either a .chm or .hlp file.
      Once you have specified the helpfile and context, then clicking on the Help button will display the helpfile that was specified in code.

      Although this appears to rule out using the MsgBox function for the purpose you have in mind, it should be pretty easy to do what you need with a userform – you can add a command button that has a “Help” caption, and which when clicked would show your Help userform.

      Just as an added note: when using the pre tags to post formatted code, it’s best to use line continuation characters to keep long lines from scrolling way off the end of the screen (I should know; Geoff has rapped my knuckles over this one on occasion 🙂

      Gary

      • #527039

        Thanks Gary,

        I will use a form instead of the msgbox, and I will use the underscore in the future…

        Thanks,

    Viewing 0 reply threads
    Reply To: MsgBox Return Value

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: