can someone tell me how to put a picture on a msgbox? or even just an icon?

try the following sample code.

MsgBox("Do you really wish to quit this program ?", vbOKCancel + vbQuestion, "Confirmation")

Debasisdas code will show the default question icon. By using vbInformation, the indormation icon will show, vbExclamation will show the exclamation icon.

Did you want to add your own icon on the message box?

andreRet yes, I want to put my own icon or image in the msgbox can it be possible?

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!:)

wow. you definitely are good at this one. just one question. are the codes that come after the apostrophes are comments? :)

thanks anyways!

Yes, it is code, they are commented because I was not really using the code. You can uncomment them by deleting the apostrophe if you are going to use a custom message box or OkCancel message form.:)

ok thanks a lot! you're an angel. this post will surely put your points higher! ;)

This question has already been answered. Start a new discussion instead.