Not with windows default message box. I have written my own message box which works wonders. Try it, its free.:)
In a module, add the following. I have uncommented a lot of the code because I'm not really using all of the message box styles.
Option Explicit
Public Function MsgQuestion(Msg As String, Title As String, FirstButton As String, SecondButton As String) As String
With frmMsgQuestion
.lblTitle.Caption = Title
.lblMessage.Caption = Msg
.cmdReturn(0).Caption = FirstButton
.cmdReturn(1).Caption = SecondButton
'.Image1(0).Picture = .imglstMessage.ListImages(2).Picture
'.image2(1).Picture = .imglstMessage.ListImages(3).Picture
.Show vbModal
DoEvents
MsgQuestion = .Tag
Unload frmMsgQuestion
End With
End Function
Public Function MsgCustom(Msg As String, Title As String, FirstButton As String, SecondButton As String) As String
'With frmMsgCustom
'.lblTitle.Caption = Title
'.lblMessage.Caption = Msg
'.cmdReturn(0).Caption = FirstButton
'.cmdReturn(1).Caption = SecondButton
'.image1(0).Picture = .imglstMessage.ListImages(2).Picture
'.image2(1).Picture = .imglstMessage.ListImages(3).Picture
'.Show vbModal
'DoEvents
'MsgCustom = .Tag
'Unload frmMsgCustom
'End With
End Function
Public Function MsgYesNo(Msg As String, Title As String, FirstButton As String, SecondButton As String) As String
'With frmMsgYesNo
'.lblTitle.Caption = Title
'.lblMessage.Caption = Msg
'.cmdReturn(0).Caption = FirstButton
'.cmdReturn(1).Caption = SecondButton
'.image1(0).Picture = .imglstMessage.ListImages(2).Picture
'.image2(1).Picture = .imglstMessage.ListImages(3).Picture
'.Show vbModal
'DoEvents
'MsgYesNo = .Tag
'Unload frmMsgYesNo
'End With
End Function
Public Function MsgOkOnly(Msg As String, Title As String, FirstButton As String, SecondButton As String) As String
With frmMsgOkOnly
.lblTitle.Caption = Title
.lblMessage.Caption = Msg
.cmdReturn(0).Caption = FirstButton
'.cmdReturn(1).Caption = SecondButton
'.image1(0).Picture = .imglstMessage.ListImages(2).Picture
'.image2(1).Picture = .imglstMessage.ListImages(3).Picture
.Show vbModal
DoEvents
MsgOkOnly = .Tag
Unload frmMsgOkOnly
End With
End Function
Public Function MsgOkCancel(Msg As String, Title As String, FirstButton As String, SecondButton As String) As String
'With frmMsgOkCancel
'.lblTitle.Caption = Title
'.lblMessage.Caption = Msg
'.cmdReturn(0).Caption = FirstButton
'.cmdReturn(1).Caption = SecondButton
'.image1(0).Picture = .imglstMessage.ListImages(2).Picture
'.image2(1).Picture = .imglstMessage.ListImages(3).Picture
'.Show vbModal
'DoEvents
'MsgOkCancel = .Tag
' Unload frmMsgOkCancel
'End With
End Function
Set up your message form, which will be your new message box system in your application. Have a look at the control names and form names, otherwise an error will be raised. The code under your message form -
Private Sub cmdReturn_Click(Index As Integer)
frmMsgOkCancel.Hide
frmMsgOkCancel.Tag = cmdReturn(Index).Caption
End Sub
Under your normal form from where the message will be called, the following code -
Dim strMessage As String
strMessage = MsgQuestion("This Is My Own MessageBox. Do You Like It?", "My Message", "Ok, I Like It", "No, I Hate It")
Let me know if there is something you don't understand. This will surely give me some reputation points!:)