View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
losmac losmac is offline
external usenet poster
 
Posts: 27
Default message boxes and buttons

In my opinion You can not defined buttons in MSGBOX function, but You can
create Your custom form with these buttons.

How to do this?
1) Create new form with 3 buttons on it.
Change name for form to FrmMsgBox

Name for one button change to CmdCancel
Set it Cancel property to True

Name for second button change to CmdRemove

Name for Button1 change to CmdCorrect
Set it Default property to True

Insert code below
===FrmMsgBox Module===
Option Explicit

Private Sub CmdCancel_Click()
myAnswer = ansCancel
Unload Me
End Sub

Private Sub CmdCorrect_Click()
myAnswer = ansCorrect
Unload Me
End Sub

Private Sub CmdRemove_Click()
myAnswer = ansRemove
Unload Me
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub
=====================

2) Insert new module
=======Module1========
Public myAnswer As Long
Public Const ansCorrect As Long = 0
Public Const ansRemove As Long = 1
Public Const ansCancel As Long = 2

Sub ZAZAZAZA()

Load FrmMsgBox
FrmMsgBox.Caption = "Do You ...."
FrmMsgBox.Label1.Caption = "Do You ...."
FrmMsgBox.Show

Select Case myAnswer
Case ansCorrect
MsgBox "Correct"
Case ansRemove
MsgBox "Remove"
Case ansCancel
MsgBox "Cancel"
End Select
End Sub
=====================

RUN IT!
TEST IT!
IT WORKS!!!!!!!!!!!!!!!!!

--
Sorry for my language, I'm still learning
losmac

Uzytkownik "Steven Wathen" napisal w
wiadomosci ...

I know you can create message boxes with buttons yes,no,cancel using
vbyesnocancel. Is there anyway i can create user defined buttons to say
"Correct, Remove and Cancel" and how would i then use the decision the
user makes from these to direct my program?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!