in visual basic in studio if this is used for giving a message
MsgBox("hello", 4, "status")
how to manipulate the result yes or no from the msgbox like this should happen if the user gives no and this should happen if no
in visual basic in studio if this is used for giving a message
MsgBox("hello", 4, "status")
how to manipulate the result yes or no from the msgbox like this should happen if the user gives no and this should happen if no
You need to check whether MsgBox
returned vbYes
.
For example:
If vbYes = MsgBox("hello", vbYesNo, "status") Then
'Do things
Else
'Don't do things
End If
MsgBox Function (Visual Basic)
Lesson 10: Introduction to VB Built-in Functions
Sample code:
Private Sub Test_Click()
Dim testMsg As Integer
testMsg = MsgBox("Click to test", 1, "Test message")
If testMsg = 1 Then 'User clicked on OK button
Display.Caption = "Test Succeeded"
Else 'User clicked on Cancel button
Display.Caption = "Test failed"
End If
End Sub