关于vb.net计时的信息

VB.NET 计时器的问题

不对。步骤如下:

创新互联2013年开创至今,先为竞秀等服务建站,竞秀等地企业,进行企业商务咨询服务。为竞秀企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

添加一个label标签名字label1 用来显示时间

再添加一个timer控件 名字timer1 interval属性=1000 用来计时

窗体添加代码

Dim t As Date '用来记录时间

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As _

System.EventArgs) Handles Timer1.Tick

t = t.AddSeconds(1)

Label1.Text = "登录时间:" t.TimeOfDay.ToString

End Sub

VB.net module中如何使用计时器?

控制台调用Timer和窗体是类似的。首先在项目引用里面加入System.Windows.Forms程序集,然后在代码顶部引入命名空间:

Imports System.Windows.Forms

在控制台的Module中声明一个计时器:

Private WithEvents Timer1 As New Timer()

把计时器的Tick事件静态绑定到处理函数中:

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

'一些代码

End Sub

在需要开始计时的地方,修改其Interval、Enabled属性:

Timer1.Interval = 1000

Timer1.Enabled = True

VB.NET,如何用TIMER控件计时

这种功能用不到TIMER,TIMER控件用在这种地方也不适合。(假如你所统计的时间很短,在几分中内话,可以使用,假如你统计的时间很长:几小时、几天几夜,建议改用以下方式):

在你需要开始计时的地方加入一个记录当前时间,在你想结束的地方也得到一个当前时间。然后将两个时间相减。

希望以上思路可以帮到你。

VB.net中如何用timer控件编出一个简单的倒计时器?

Dim tCount As Integer '用来计数

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles MyBase.Load

tCount = 10

Timer1.Interval = 1000 '每秒执行一次

Timer1.Enabled = True

End

Sub

Private Sub

Timer1_Tick(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Timer1.Tick

tCount -= 1

If tCount = 0 Then

MessageBox.Show("时间到")

Timer1.Enabled = False

End If

End

Sub

VB.net做计时器。。。

加个timer,两个label,以下是代码:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Label1.Text = Format(Now(), "yyyy-MM-dd HH:mm:ss")

End Sub

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

Label2.Text = Format(Now(), "yyyy-MM-dd HH:mm:ss")

If DateDiff(DateInterval.Hour, DateTime.Parse(Label1.Text), DateTime.Parse(Label2.Text)) = 3 Then

MsgBox("超过3小时了!", , "信息提示")

Timer1.Enabled = False 'timer终止,不然会一直谈对话框!

End If

End Sub

vb.net 我想编一个计时器,计时器显示格式00:00:00 (只能用一个label)怎么做?

Dim hour, min, sec As Integer

Private Sub Command1_Click()

If Command1.Caption = "开始计时" Then

Command1.Caption = "停止计时"

Timer1.Enabled = True

Else

If Command1.Caption = "停止计时" Then

Command1.Caption = "开始计时"

Timer1.Enabled = False

End If

End If

End Sub

Private Sub Form_Load()

hour = 0

min = 0

sec = 0

Label1.Caption = Format(hour, "00") ":" Format(min, "00") ":" Format(sec, "00")

End Sub

Private Sub Timer1_Timer()

sec = sec + 1

If sec 59 Then

sec = 0

min = min + 1

If min 59 Then

min = 0

hour = hour + 1

End If

End If

Label1.Caption = ""

Label1.Caption = Format(hour, "00") ":" Format(min, "00") ":" Format(sec, "00")

End Sub


本文标题:关于vb.net计时的信息
文章起源:http://scyanting.com/article/hishss.html