Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Dallas plus 20 miles or so, Texas, USA
    Posts
    876
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MsgBox Return Value

    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:

    <pre>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</pre>


    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,

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: MsgBox Return Value

    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

  3. #3
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Dallas plus 20 miles or so, Texas, USA
    Posts
    876
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MsgBox Return Value

    Thanks Gary,

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

    Thanks,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •