Discussion Locked
0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am just learning excell VBA and on a command button I am putting in MsgBox lines in VB.I also add a no button in the msgbox.What line would I put in to make the msgbox close when you press the no button?
3 replies
by bill_h
The following code will display a succession of message boxes as long as the user clicks on the "Yes" button; if the user clicks on a "No" button, they will be returned to the form containing CommandButton1.
Private Sub Command1_Click()
'This variable indicates which MsgBox button was clicked
Dim iResult As Integer
iResult = MsgBox(Prompt:="test box", Buttons:=4)
If iResult = vbYes Then
iResult = MsgBox("press no to close", Buttons:=4)
If iResult = vbYes Then
iResult = MsgBox("test 3", Buttons:=4)
If iResult = vbYes Then
MsgBox "test 4", Buttons:=4
End If
End If
End If
End Sub
by dcarrier
Poster rated this answer
by dcarrier
This question was closed by the author
This discussion is closed to new replies.
Trending Software posts
Sort by Trending
0 helpful
1 reply
0 helpful
5 replies
0 helpful
0 replies
1 helpful
1 reply
Question Unanswered
How Are Teams Testing AI-Generated Code Before Production?
0 helpful
0 replies