PDA

View Full Version : Solved: Custom Message Box



bkudulis
09-30-2004, 04:48 AM
I am trying to create a custom message box similar to the VBYesNO. Instead of the buttons being Yes or No I would like them to be Preview or Print.

Steiner
09-30-2004, 05:34 AM
I think you'll have to create your own userform with labels and buttons just as you need them + add a function to evaluate what was clicked so you can call the whole thing just like an ordinary msgbox.

I once did this with a YesNoAbort-Box which should allow the user to go back 1 step. Maybe you can change this example to fit your needs.

This was the code from the form:


Private Sub cmd_Abbrechen_Click()
Me.Tag = "Abbrechen"
Me.Hide
End Sub
Private Sub cmd_Ja_Click()
Me.Tag = "Ja"
Me.Hide
End Sub
Private Sub cmd_Nein_Click()
Me.Tag = "Nein"
Me.Hide
End Sub
Private Sub cmd_Zur?ck_Click()
Me.Tag = "Zur?ck"
Me.Hide
End Sub
Private Sub UserForm_Activate()
cmd_Ja.SetFocus
End Sub


And this was the calling sub:

Public Function YesNo(Formulartitel$, Fragetext$) As String
With frm_YesNo
.Caption = Formulartitel
.lbl_Frage.Caption = Fragetext
.Show
YesNo = .Tag
End With
Unload frm_YesNo
End Function


To use it:
Dim answer as String
answer = YesNo("A Question","Do you want that?")
If answer = "Ja" then ....