how can i put an if statement in a OkCancel Msgbox ..

for example when i choose OK .. it will perform the code ..

and if I Cancel it will not perform the code?

Recommended Answers

All 3 Replies

Dim result As DialogResult = MessageBox.Show("Some text", "Some caption", MessageBoxButtons.OKCancel)
        If result = Windows.Forms.DialogResult.OK Then
            'do something

        ElseIf result = Windows.Forms.DialogResult.Cancel Then
            'do something else

        End If

Thanks a Lot ..

Thanks. It worked in my VB2010 also.

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.