private form_load sub ()
call Timer1_Timer ()
timer1.enabled=true
timer1.interval=100
end sub
sub Timer1_Timer()
text1.text=year(now)
text2.text=month(now)
text3.text=date(now)
text4.text=formatdatetime(now, "hh:mm:ss")
end sub
sub timer1_ontimer()
timer1.enable=false
text1.text=year(now)
text2.text=month(now)
text3.text=date(now)
text4.text=formatdatetime(now, vbLongTime)
timer1.enable=true
end sub
’以下是纯代码操作,不用楼主手动添加任何控件,新建工程粘贴代码进去即可
Private WithEvents Timer1 As Timer
Private Sub Form_Load()
Me.Width = 10000
Me.Height = 6000
Form1.Controls.Add "VB.Label", "label1", Form1 '标签1
Form1.Controls.Add "VB.Label", "label2", Form1 '标签2
Set Timer1 = Controls.Add("VB.Timer", "Timer1") '计时器
With Form1!Label1 '初始化
.Top = 800
.Left = 1000
.FontSize = 30
.Caption = "今天是 " & Year(Now) & " 年 " & Month(Now) & " 月 " & Day(Now) & " 日"
.AutoSize = True
End With
With Form1!Label2 '初始化
.Top = 3200
.Left = 1000
.FontSize = 30
.AutoSize = True
End With
Form1!Label1.Visible = True
Form1!Label2.Visible = True
Form1!Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Form1!Label2.Caption = "现在是北京时间:" & Format(Now, "hh:mm:ss")
End Sub
需要你的邮箱,做好了好发给你。