Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2010
    Location
    UK
    Posts
    160

    Unanswered: pop-up message with variable options

    Hi there,

    Is it possible to use like a message box to pop up which gives the user the option to select from say two variables / options and then store that selection?

    Thanks
    Marcus

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    you could bastardise a message box with two values and a yes no, or a yes/no/cancel
    or create a modal form that does what you want
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Sep 2010
    Location
    UK
    Posts
    160
    i've only got two options to choose from so I'll try the message box. thanks for the advice.

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    When using MsgBox() you are limited to using the buttons options it provides (Abort/Retry/Ignore, OK/Cancel, OK, Retry/Cancel, Yes/No, Yes/No/Cancel).
    In some circumstances you can "force" (twist) the meaning of these buttons. Ex.
    Code:
    Function TestMsgBox()
    
        Dim lngAnswer As Long
        Dim strMsg As String
        
        strMsg = "Do you want to perform monthly calculation?" & vbNewLine & _
                "  - Press Yes for monthly calculation." & vbNewLine & _
                "  - Press No for weekly calculation." & vbNewLine & _
                "  - Press Cancel to abort the calculation process."
        Select Case MsgBox(strMsg, vbYesNoCancel, "Please select a calculation mode.")
            Case vbYes
                ' Perform monthly calculation.
            Case vbNo
                ' Perform weekly calculation.
            Case vbCancel
                ' Abort the calculation process.
        End Select
                         
    End Function
    On the other hand, you can also create your own MessageBox function using a modal form, where you can define any buttons you want. Several solutions are available for download. See for instance:
    VB6 Custom MsgBox form - VBForums
    Custom VBA Message Box
    Or search on Google for "Custom MsgBox".
    Have a nice day!

  5. #5
    Join Date
    Sep 2010
    Location
    UK
    Posts
    160
    that's spot on!! thanks for the code.

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!

    The attached file contains a custom solution that can accept one to six command buttons.

    You can add the Frm_MessageBox form, the Cls_MessageBox Class module and the Mod_MessageBox to your application then call the MessageBox() function. The function TestMessageBox() in Mod_MessageBox shows how it works.
    Attached Files Attached Files
    Have a nice day!

  7. #7
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!

    The attached file contains a custom solution that can accept one to six command buttons.

    You can add the Frm_MessageBox form, the Cls_MessageBox Class module and the Mod_MessageBox to your application then call the MessageBox() function. The function TestMessageBox() in Mod_MessageBox shows how it works.
    Attached Files Attached Files
    Have a nice day!

Posting Permissions

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