重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
不对。步骤如下:
城北ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!
添加一个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
控制台调用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
用Timer控件吧,设置1秒执行1次。然后直接在Timer中写代码,将全全局的值来
减减1,如果值为0,则停止Timer
跳出提示框
以下示例:
int
Tatal
=
100;
Timer.Inveral
=
1000;
Timer_()
{
if
(
Tatal
==
0)
{
MessageBox.Show("完成!");
Timer.Stop();
}
else
{
Tatal
--;
}
}
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