2014-01-24 69 views
2

對你們大家好日子我有這個程序是一個瑣事遊戲,我想通過form.show將一個窗體作爲啓動畫面()和form.hide,我想問我怎樣才能通過顯示至少3秒來設置窗體並再次隱藏它?在此先感謝Form.show和Form.Hide時間間隔Vb.Net

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click 
    If Label1.Text = "Who invented the airplane?" And TextBox1.Text = "third" Then 

     Label2.Text = (Label2.Text) + 1 

     correctmsg.Show() 
     correctmsg.Hide() 

     Label1.Text = "Who invented the telephone?" 
     Return 'Don't do any more checks this time around 

    ElseIf Label1.Text = "Who invented the airplane?" Then 
     'Reason ElseIf (In case the question was 'who invented the telephone' then the first errormessage should not not be shown) 
     wrongmsg.Show() 
     Return 

    End If 

回答

1

放定時器timer1splashscreenFORM它設置爲enabled=false 雙擊timer1把這個代碼me.close()

現在從你想要做的那個形式

dim mysplash as new splashscreenFORM 
mysplash.timer1.Interval = 3000 
mysplash.timer1.start() 
mysplash.show() 

飛濺形式應該出現3秒

+0

非常感謝你的解決方案:) – TheNewbie

+0

@ user3231002,如果這個答案是你的問題,那麼你應該把它標記爲這樣,以便其他用戶有同樣的問題可以看到答案,並且也爲了讓人工智能是願意在未來幫助你。 – davidsbro

+0

@davidsbro確定先生,因爲我只是新的在這裏我不知道如何標記:p – TheNewbie

1

您可以使用Thread.sleep(3000),如果你不想讓你的GUI做別的。如果你想讓你的GUI正常工作時,會顯示此correctmsg形式,可以用下面的代碼

correctmsg.Show() 

Dim SW2 As New Stopwatch 
    SW2.Start() 
    Do 
     Application.DoEvents() 
    Loop Until SW2.ElapsedMilliseconds >= 3000m 
correctmsg.Hide() 
2

試試這個:

Public tTimer As Timer 
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load 
    tTimer = New Timer() 
    tTimer.Interval = 3000 
    tTimer.Enabled = False 
    AddHandler tTimer.Tick, AddressOf OnLayouttimerTick 
End Sub 

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click 
If Label1.Text = "Who invented the airplane?" And TextBox1.Text = "third" Then 

    Label2.Text = (Label2.Text) + 1 

    correctmsg.Show() 
    tTimer.Start() 

    Label1.Text = "Who invented the telephone?" 
    Return 'Don't do any more checks this time around 

ElseIf Label1.Text = "Who invented the airplane?" Then 
    'Reason ElseIf (In case the question was 'who invented the telephone' then the first errormessage should not not be shown) 
    wrongmsg.Show() 
    Return 

End If 

Private Sub OnLayouttimerTick(sender As Object, e As EventArgs) 
    correctmsg.Hide() 
End Sub 
+0

此方法有一個問題。如果有人在correctmsg表單關閉之前再次點擊該按鈕,第二次它會在3s之前關閉 –

+0

ok ..感謝您更新我! –