1

看我有这个从 5 到 1 的简单 vb.net 代码,然后说捕获!单击开始按钮后,我需要连续执行 4 次.. 我尝试了一个直到循环,但它没有用,我是这里的新手,所以请帮忙..

Public Class Form_welcome
    Dim Count As Integer

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

        Count -= 1
        Label2.Text = Count
        If (Count = 0) Then
            Timer1.Enabled = False
            Label2.Hide()
            Label3.Show()
        End If

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Count = 5
        Timer1.Enabled = True
        Label2.Text = Count
        Timer1.Interval = 1000
    End Sub

End Class
4

2 回答 2

0

像这样的东西?

Public Class Form_welcome

    Dim Count As Integer
    Dim pictureCount as integer = 4

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

        Count -= 1
        Label2.Text = Count
        If (Count = 0) Then
            pictureCount -=1
            If pictureCount = 0 then
                Timer1.Enabled = False
           End If
                'take a picture
            Label2.Hide()
            Label3.Show()
            Count = 5
        End If

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Count = 5
        Timer1.Enabled = True
        Label2.Text = Count
        Timer1.Interval = 1000
    End Sub

End Class
于 2012-11-20T13:06:36.767 回答
0

公共类 Form_welcome Dim Count As Integer

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

    Admin_Login.Show()
    Me.Hide()

End Sub

Private Sub Form_welcome_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    Application.Exit()

End Sub

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

    Button4.Hide()
    Button5.Hide()
    Button6.Hide()


    'Timer1.Enabled = True
    'Label2.Text = Count
    'Timer1.Interval = 1000

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Count -= 1
    'Label2.Text = Count
    If (Count = -1) Then
        Timer1.Enabled = False
        Label3.Show()
        Label3.Hide()
        Label2.Hide()
        Button4.Show()
        Button5.Show()
        Button6.Show()
        PictureBox4.Hide()
        PictureBox3.Show()
        pict1.Show()
        pict2.Show()
        pict3.Show()
        pict4.Show()
        Button2.Hide()
    End If
    If (Count Mod 3) = 0 Then
        Label2.Text = "Captured!"
    Else
        Label2.Text = Count

    End If


End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Count = 12
    Timer1.Enabled = True
    Label2.Text = Count
    Label2.Show()
    Timer1.Interval = 1000
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
    Application.Exit()

End Sub


Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
    Button2.Show()
    Button4.Hide()
    Button5.Hide()
    Button6.Hide()
    PictureBox3.Hide()
    pict1.Hide()
    pict2.Hide()
    pict3.Hide()
    pict4.Hide()
    PictureBox4.Show()

End Sub

结束类

于 2012-11-21T02:57:57.970 回答