我正在將一個訊息框編碼到我的游戲中,以確認一個程序已完成。我的訊息框已顯示,并且正在運行。當我單擊“確定”時,如何讓它運行我的代碼的新部分?(我不知道如何將代碼連接到訊息框中的按鈕)1
uj5u.com熱心網友回復:
你可以這樣做:
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
或者,您可以只在 MsgBox 之后呼叫您的一個 subs 而不會得到結果,因為無論如何只會回傳一個結果。
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
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/459312.html
