Hey all,

I am trying to display a message asking if the user is sure that they want to close just before closing.

Here's what I've got...and it's only telling me that there's something wrong with the word "Message" after the MessageBox.Show part

Private Sub xExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xExitButton.Click

        Dim button As DialogResult

        button = MessageBox.Show(Message, _
        "Are you sure you want to exit this application?", _
        MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1)

        If button = Windows.Forms.DialogResult.Yes Then
            Me.Close()
        Else
        End If


    End Sub

Help?...Anyone?

Recommended Answers

All 3 Replies

i was modified your code.
your messagebox parameter is not completed, that why errors coming out.

Private Sub xExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xExitButton.Click

        Dim button As DialogResult

        button = MessageBox.Show _
        ("Are you sure you want to exit this application?", _
        "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)

        If button = Windows.Forms.DialogResult.Yes Then
            Me.Close()
        Else
        End If
    End Sub

btw this thread for vb.net question not for vb6...

commented: Good +1
commented: Yupy +1

btw this thread for vb.net question not for vb6...

thank you very much. and i'm sorry i didn't ask the question in the right place. where should i direct my VB6 questions to?

you can post all vb question in this section(vb6) but just for vb.net question like this thread please post on vb.net section.
and don't forget to mark this thread solved.
Happy coding friend :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.