Vb.net 奇怪的计时器

Vb.net 奇怪的计时器,vb.net,timer,Vb.net,Timer,嗨,伙计们,我还有一个问题是关于计时器的。我想显示3秒钟的表单只显示了大约半秒钟。请先帮我谢谢 主要表格编号: Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click 'question 1 If Label1.Text = "Who invented the airplane?" And TextBox1.Text = "t

嗨,伙计们,我还有一个问题是关于计时器的。我想显示3秒钟的表单只显示了大约半秒钟。请先帮我谢谢

主要表格编号:

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click
    'question 1
    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
Public Class correctmsg

Private Sub correctmsg_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Dim mysplash As New correctmsg
    mysplash.Timer1.Interval = 3000

End Sub
启动表单代码:

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click
    'question 1
    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
Public Class correctmsg

Private Sub correctmsg_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Dim mysplash As New correctmsg
    mysplash.Timer1.Interval = 3000

End Sub
末级

类似这样的内容:

Public Class correctmsg
  ' correctmsg == mysplash ??? so this is a form??


 Private Sub correctmsg_Load(ByVal sender As System.Object, 
      ByVal e As System.EventArgs) Handles MyBase.Load

      Timer1.Interval = 3000    ' could be a timer here

 End Sub

 Public Sub ShowMsg
     Timer1.Enabled = true
     me.Visible = True
 End Sub

 Private Sub Timer1_Tick(ByVal sender As System.Object, 
           ByVal e As System.EventArgs) Handles Timer1.Tick

     Timer1.Enabled = False
     Me.Visible = False

 End Sub
 End Class
我只是通过使表单可见来显示表单。不需要制作新表单。计时器过期时,隐藏窗体并禁用计时器。要使用它:

    correctmsg.ShowMsg
    ' this was hiding the form as soon as it shows:
    'correctmsg.Hide()

您的代码似乎在显示后立即将其隐藏。让另一个窗体的勾号事件隐藏它。设置时间间隔并在表单加载中启用。@Promotix嗨,先生,您能详细说明一下吗?谢谢如果你将间隔设置为18000,会发生什么?另外,如果你去掉这一行,
correctmsg.Hide()
?@davidsbro,当我去掉correctmsg.Hide()时,表单将只显示而不关闭自己…即使我更改了间隔,correctmsg表单也会在半秒钟内消失好的,我的意思是尝试@puropoix建议的方法,再去掉
correctmsg.Hide()
谢谢,先生,我刚刚更改了我正确的MSG表格上的间隔时间,因为我忘了……)