1、添加一个“label控件”命名为label
2、添加一个“timer控件”命名为timer1
3、设置“timer1”的“Interval属性”为1000
使用到的代码:
Dim Hour As Integer '小时
Dim Min As Integer '分钟
Dim Sec As Integer '秒
Private Sub Form_Load()
Hour = 0
Min = 0
Sec = 0
Label1.Caption = "00 : 00 : 00"
End Sub
Private Sub Timer1_Timer()
Dim strHour As String
Dim strMin As String
Dim strSec As String
Sec = Sec + 1
If Sec >= 60 Then
Sec = 0
Min = Min + 1
If Min >= 60 Then
Min = 0
Hour = Hour + 1
If Hour >= 24 Then
Hour = 0
End If
End If
End If
If Hour < 10 Then
strHour = "0" 并悉& Hour
Else
strHour = Hour
End If
If Min < 10 Then
strMin = "绝告乎0" & Min
Else
strMin = Min
End If
If Sec < 10 Then
strSec = "0" & Sec
Else
友袭 strSec = Sec
End If
Label1.Caption = strHour & " : " & strMin & " : " & strSec
End Sub
提供一个弯升思路,就是用一张BMP的素材,上面有各埋拦老种数字的。
使用时,用API裁剪出上面的某个衡薯数字,显示到DC里(就是PictureBOX之类)。
依这个思路我用VC6的MFC实现过……