Results 1 to 4 of 4

Thread: msgbox buttons

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    Kent, UK
    Posts
    41

    Question

    1) I've got a msgbox with 2 button, ok and cancel. I want the ok button to unload everything (i.e. itself and the main form) and the cancel button just to unload itself(msgbox) and go back into the mainform. My Code so far is: msgbox "hello",vbOKCancel...(then what?!) I hope you underdstood that! (Please can you give me an e.g line as I'm fairly new to VB6)

    2) How do you change the names of the buttons on the msgbox? (Please can you give me an e.g line as I'm fairly new to VB6)

    Thank you very much

    moonfruit

  2. #2
    Lively Member
    Join Date
    Apr 2000
    Posts
    70
    well, if you call the MsgBox function with:
    Code:
    x = MsgBox ("Press a button", vbOkCancel, "Title")
    with any types of buttons you like, you can then do:
    Code:
    Select Case x
    Case vbOK 'OK was pressed
         'Your code here
    Case vbCancel 'Cancel was pressed
         'Your code here
    Case vbAbort 'Abort was pressed
         'Your code here
    Case vbRetry 'Retry was pressed
         'Your code here
    Case vbIgnore Ignore was pressed
         'Your code here
    Case vbYes 'Yes was pressed
         'Your code here
    Case vbNo 'No was pressed
         'Your code here
    End Select
    hope that helps..
    Daniel Rose
    VB 5.0 Enterprise.
    irc:irc2.dynam.ac

    If TheCodeInTheSig() Is Not Lame() Then IDontKnowWhatIs()

  3. #3
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    I don't know how to change the name of the button, there must be a way,but for now u can do a form that look like a message box, then you would be able to do what ever you want with it.

  4. #4
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Cool Message Box

    Your code should look like this:


    Private Sub Command1_Click() 'COMMAND BUTTON CLICK EVENT

    If MsgBox("Hello", vbExclamation Or vbOKCancel, _
    "Exit") = vbOK Then
    Unload Me 'UNLOADS THE FORM
    End If

    End Sub


    If the cancel button is pressed, nothing will happen.
    The "vbExclamation" tells it to show the yellow exclamation point icon and "vbOKCancel" gives you the OK and Cancel buttons. You must use "Or" between these. "And" makes more sense, but will not work.

    You can use "vbCritical Or vbOKCancel". This shows the red X icon and OK and Cancel Buttons. There are several Icon and button choices. Just play around with it.

Posting Permissions

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



Click Here to Expand Forum to Full Width