关于vb.net初学者,倒计时器的开发

此文章已过期!!!

请移步:(15条消息) vb.net倒计时器(3.0,版本优化,不熟练的配置文件)_大Mod制造者abfun的博客-CSDN博客

上次我写了一次记事本,毛病百出,想想也不行,那这一次小虞又出花样了,此灵感来源于班主任组织考试,却在希沃白板上找不到计时器(其实闹钟和时钟也可以使用)

下来开始安排代码:

form1

Public Class Form1
    Dim k As String
    Dim h As Integer
    Dim m As Integer
    Dim s As Integer

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Form2.Show()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        k = 1
        Timer1.Interval = 1000 '每秒执行一次
        Timer1.Enabled = True

    End Sub

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



    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        TextBox1.Text = 0
        TextBox2.Text = 0
        TextBox3.Text = 0
        Timer1.Enabled = False
    End Sub


    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        TextBox3.Text = TextBox3.Text - 1
    End Sub

    Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged

        Dim a, b, c As String
        a = Val(TextBox1.Text)
        b = Val(TextBox2.Text)
        c = Val(TextBox3.Text)
        TextBox1.Text = a
        TextBox2.Text = b
        TextBox3.Text = c

        If c = -1 Then
            TextBox3.Text = 59
            TextBox2.Text -= 1
        End If
        If k = 1 Then 'load check
            If a = 0 Then
                If b = 0 Then
                    If c = 0 Then
                        My.Computer.Audio.Play("C:\Windows\Media\Ring10.wav")
                        Timer1.Enabled = False
                    End If
                End If
            End If
        End If
    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Timer1.Enabled = False
    End Sub

    Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
        Dim a, b, c As String
        a = Val(TextBox1.Text)
        b = Val(TextBox2.Text)
        TextBox1.Text = a
        TextBox2.Text = b
        If b = -1 Then
            TextBox2.Text = 59
            TextBox1.Text -= 1
        End If
    End Sub

    Private Sub Button6_Click_1(sender As Object, e As EventArgs) Handles Button6.Click
        form3.show()
    End Sub

End Class

form2(设置计时器)

 

Public Class Form2
    Dim h As String
    Dim m As String
    Dim s As String
    Dim a As String
    Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click

    End Sub

    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        a = TextBox1.Text
        a = a + 1
        TextBox1.Text = (a)
    End Sub

    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        a = TextBox2.Text
        a = a + 1
        TextBox2.Text = (a)
    End Sub

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        If TextBox1.Text < 0 Then
            TextBox1.Text = 2
        End If
        If TextBox1.Text > 2 Then
            TextBox1.Text = 0
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        a = TextBox1.Text
        a = a - 1
        TextBox1.Text = (a)
    End Sub

    Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
        a = TextBox3.Text
        a = a + 1
        TextBox3.Text = (a)
    End Sub

    Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        a = TextBox4.Text
        a = a + 1
        TextBox4.Text = (a)
    End Sub

    Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
        a = TextBox5.Text
        a = a + 1
        TextBox5.Text = (a)
    End Sub

    Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
        a = TextBox6.Text
        a = a + 1
        TextBox6.Text = (a)
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        a = TextBox2.Text
        a = a - 1
        TextBox2.Text = (a)
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        a = TextBox3.Text
        a = a - 1
        TextBox3.Text = (a)
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        a = TextBox4.Text
        a = a - 1
        TextBox4.Text = (a)
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        a = TextBox5.Text
        a = a - 1
        TextBox5.Text = (a)
    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        a = TextBox6.Text
        a = a - 1
        TextBox6.Text = (a)
    End Sub

    Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
        If TextBox2.Text < 0 Then
            TextBox2.Text = 3
        End If
        If TextBox2.Text > 3 Then
            TextBox2.Text = 0
        End If
    End Sub

    Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
        If TextBox3.Text < 0 Then
            TextBox3.Text = 5
        End If
        If TextBox3.Text > 5 Then
            TextBox3.Text = 0
        End If
    End Sub

    Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged
        If TextBox4.Text < 0 Then
            TextBox4.Text = 9
        End If
        If TextBox4.Text > 9 Then
            TextBox4.Text = 0
        End If
    End Sub

    Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles TextBox5.TextChanged
        If TextBox5.Text < 0 Then
            TextBox5.Text = 5
        End If
        If TextBox5.Text > 5 Then
            TextBox5.Text = 0
        End If
    End Sub

    Private Sub TextBox6_TextChanged(sender As Object, e As EventArgs) Handles TextBox6.TextChanged
        If TextBox6.Text < 0 Then
            TextBox6.Text = 9
        End If
        If TextBox6.Text > 9 Then
            TextBox6.Text = 0
        End If
    End Sub

    Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
        TextBox1.Text = 0
        TextBox2.Text = 0
        TextBox3.Text = 0
        TextBox4.Text = 5
        TextBox5.Text = 0
        TextBox6.Text = 0
    End Sub

    Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
        TextBox1.Text = 0
        TextBox2.Text = 0
        TextBox3.Text = 0
        TextBox4.Text = 0
        TextBox5.Text = 0
        TextBox6.Text = 0
    End Sub

    Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
        h = Val(TextBox1.Text & TextBox2.Text)
        m = Val(TextBox3.Text & TextBox4.Text)
        s = Val(TextBox5.Text & TextBox6.Text)
        Form1.TextBox1.Text = h
        Form1.TextBox2.Text = m
        Form1.TextBox3.Text = s

    End Sub

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub
End Class

 这一次源码文件就不放了,自己探索八!!(还需要一个timer控件)

花了我2个小时,淦哪,

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值