'在Form中添加一个PictureBox控件,Name=Picture1 '添加一个Timer控件,Name=Timer1 '复制以下代码到Form Option Explicit 'API函数 Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long'窗体载入 Private Sub Form_Load() Picture1.AutoRedraw = True '自动重刷 Picture1.ScaleMode = 3 'Pixel模式 Timer1.Interval = 100 'Timer间隔 Timer1.Enabled = True '激活 End Sub'定时器事件 Private Sub Timer1_Timer() ' 左间距 顶间距 Dim L As Long, T As Long ' 当前时间 Dim NTime As String ' 清除 Picture1.Cls ' 时间更新 NTime = Format(Time, "hh:mm:ss") '输出到Picture1 TextOut Picture1.hdc, L, T, NTime, Len(NTime) ' Picture1更新 Picture1.Refresh End Sub
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As LongTextOut Picture1.hdc, 100, 100, CSTR(Now), Len(CSTR(Now))
image1.picture=picture1.image
而且要注意把autoredraw属性设为真
'添加一个Timer控件,Name=Timer1
'复制以下代码到Form
Option Explicit
'API函数
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long'窗体载入
Private Sub Form_Load()
Picture1.AutoRedraw = True '自动重刷
Picture1.ScaleMode = 3 'Pixel模式
Timer1.Interval = 100 'Timer间隔
Timer1.Enabled = True '激活
End Sub'定时器事件
Private Sub Timer1_Timer()
' 左间距 顶间距
Dim L As Long, T As Long
' 当前时间
Dim NTime As String
' 清除
Picture1.Cls
' 时间更新
NTime = Format(Time, "hh:mm:ss")
'输出到Picture1
TextOut Picture1.hdc, L, T, NTime, Len(NTime)
' Picture1更新
Picture1.Refresh
End Sub