用图像控件和计时器做蝴蝶飞舞的VB程序 5
3个回答
展开全部
在窗体上放一个Timer1控件,Label控件,开始执行按钮(start)和结束执行按钮(end)
Public start_time As String
Public end_time As String
Private Sub end_Click()
Timer1.Enabled = False
end_time = Now
MsgBox "经过的时间为" & DateDiff("s", start_time, end_time)
End Sub
Private Sub Form_Load()
Timer1.Interval = 500
Timer1.Enabled = False
Label1.Caption = "00(h):00(m):00(s)"
End Sub
Private Sub start_Click()
Timer1.Enabled = True
start_time = Now
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Format(Now, "hh""(h)"":mm""(m)"":ss""(s)""")
End Sub
不好意思哈,没考虑到秒以下的.
现在奉上.
调用API函数的GetTickCoun.其调用语句为:
Public Declare Function GetTickCount Lib "kernel32" () As Long
该函数功能:GetTickCount返回(retrieve)从操作系统启动到现在所经过(elapsed)的毫秒数
楼主你可以做个开始计时按钮和结束计时按钮,如下:
Public starttime As Long, endtime As Long
Private Sub end_time_Click()
endtime = GetTickCount
MsgBox "所经过的时间为:" & Format(endtime - starttime, "###秒###")
End Sub
Private Sub start_time_Click()
starttime = GetTickCount
End Sub
Public start_time As String
Public end_time As String
Private Sub end_Click()
Timer1.Enabled = False
end_time = Now
MsgBox "经过的时间为" & DateDiff("s", start_time, end_time)
End Sub
Private Sub Form_Load()
Timer1.Interval = 500
Timer1.Enabled = False
Label1.Caption = "00(h):00(m):00(s)"
End Sub
Private Sub start_Click()
Timer1.Enabled = True
start_time = Now
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Format(Now, "hh""(h)"":mm""(m)"":ss""(s)""")
End Sub
不好意思哈,没考虑到秒以下的.
现在奉上.
调用API函数的GetTickCoun.其调用语句为:
Public Declare Function GetTickCount Lib "kernel32" () As Long
该函数功能:GetTickCount返回(retrieve)从操作系统启动到现在所经过(elapsed)的毫秒数
楼主你可以做个开始计时按钮和结束计时按钮,如下:
Public starttime As Long, endtime As Long
Private Sub end_time_Click()
endtime = GetTickCount
MsgBox "所经过的时间为:" & Format(endtime - starttime, "###秒###")
End Sub
Private Sub start_time_Click()
starttime = GetTickCount
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
博思aippt
2024-07-20 广告
2024-07-20 广告
博思AIPPT是基于ai制作PPT的智能在线工具,它提供了4种AI制作PPT的方式,包括AI生成大纲、AI直接生成PPT、文本生成PPT、AI提炼文档生成PPT,一站式集成多种AI生成PPT的方式,可满足办公用户的不同需求和使用场景。ai生...
点击进入详情页
本回答由博思aippt提供
展开全部
'假如你所用到的组图有13张。
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 100 '控制图片切换速度
End Sub
Private Sub Timer1_Timer()
Static i As Integer
i = i + 1
Image1.Visible = False: Image2.Visible = False: Image3.Visible = False: Image4.Visible = False: Image5.Visible = False: Image6.Visible = False: Image7.Visible = False: Image8.Visible = False: Image9.Visible = False: Image10.Visible = False: Image11.Visible = False: Image12.Visible = False: Image13.Visible = False
If i = 1 Then
Image1.Visible = True
ElseIf i = 2 Then
Image2.Visible = True
ElseIf i = 3 Then
Image3.Visible = True
ElseIf i = 4 Then
Image4.Visible = True
ElseIf i = 5 Then
Image5.Visible = True
ElseIf i = 6 Then
Image6.Visible = True
ElseIf i = 7 Then
Image7.Visible = True
ElseIf i = 8 Then
Image8.Visible = True
ElseIf i = 9 Then
Image9.Visible = True
ElseIf i = 10 Then
Image10.Visible = True
ElseIf i = 11 Then
Image11.Visible = True
ElseIf i = 12 Then
Image12.Visible = True
ElseIf i = 13 Then
Image13.Visible = True
Else
Image1.Visible = True
End If
If i >= 13 Then i = 0
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 100 '控制图片切换速度
End Sub
Private Sub Timer1_Timer()
Static i As Integer
i = i + 1
Image1.Visible = False: Image2.Visible = False: Image3.Visible = False: Image4.Visible = False: Image5.Visible = False: Image6.Visible = False: Image7.Visible = False: Image8.Visible = False: Image9.Visible = False: Image10.Visible = False: Image11.Visible = False: Image12.Visible = False: Image13.Visible = False
If i = 1 Then
Image1.Visible = True
ElseIf i = 2 Then
Image2.Visible = True
ElseIf i = 3 Then
Image3.Visible = True
ElseIf i = 4 Then
Image4.Visible = True
ElseIf i = 5 Then
Image5.Visible = True
ElseIf i = 6 Then
Image6.Visible = True
ElseIf i = 7 Then
Image7.Visible = True
ElseIf i = 8 Then
Image8.Visible = True
ElseIf i = 9 Then
Image9.Visible = True
ElseIf i = 10 Then
Image10.Visible = True
ElseIf i = 11 Then
Image11.Visible = True
ElseIf i = 12 Then
Image12.Visible = True
ElseIf i = 13 Then
Image13.Visible = True
Else
Image1.Visible = True
End If
If i >= 13 Then i = 0
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用IMAGE和TIMER配合,每计时一次就随机移动一次坐标
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询