hi iam new to programming and i want to know how i tell vb.net if it was replied to a msgbox with (yes ) then do something
please help me about that

Recommended Answers

All 3 Replies

Try this:

If MessageBox.Show("Button Pressed " & CStr(Int(Button1.Text) + 1) & " times") = Windows.Forms.DialogResult.OK Then
            Button1.Text = CStr(Int(Button1.Text) + 1)
        End If

or this:

Dim result As Integer = MessageBox.Show("This is a message")
        If result = vbOK Then Button1.Text = "Something"
If MsgBox("Your Confirm Message ?", MsgBoxStyle.OKCancel, "Exit confirm") = MsgBoxResult.OK Then
         'add your code to do something if yes button pressed
Else
         ' Do nothing when cancel was pressed
End If

OK.

hi try this

dim a as string
a=msgbox("do u want to save",MsgBoxStyle.YesNo)
if a= vbyes then
do this
else
do this
end if
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.