I am coding a message box into my game to confirm a process is completed. My message box is displayed, and functioning. How can I make it where when I click OK it runs a new part of my code? (I do not know how to connect code to the buttons within a message box)1
CodePudding user response:
You could do something like this:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ProgressBar1.Value = 1
If ProgressBar1.Value = 1000 Then
Timer1.Enabled = False
Dim msgResult As MsgBoxResult = MsgBox("Program has been loaded", MsgBoxStyle.OkOnly, "Click to continue")
If msgResult = MsgBoxResult.Ok Then
DoSomething()
End If
End If
End Sub
Private Sub DoSomething()
MsgBox("You did something")
End Sub
Alternatively, you could just call one of your subs after your MsgBox without getting the result since there is only one result that would be returned anyway.
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ProgressBar1.Value = 1
If ProgressBar1.Value = 1000 Then
Timer1.Enabled = False
MsgBox("Program has been loaded", MsgBoxStyle.OkOnly, "Click to continue")
DoSomething()
End If
End Sub
Private Sub DoSomething()
MsgBox("You did something")
End Sub