vb实现图像从窗体左上角向右下角逐渐移动的代码 使用timer控件
运行初始时,移动按钮有效,停止按钮无效,且关闭定时器。单击移动按钮,激活定时器,图像开始向右下角移动,且移动按钮无效,停止按钮有效。单击停止按钮,则关闭定时器,将图像移回...
运行初始时,移动按钮有效,停止按钮无效,且关闭定时器。单击移动按钮,激活定时器,图像开始向右下角移动,且移动按钮无效,停止按钮有效。单击停止按钮,则关闭定时器,将图像移回到左上角,且移动按钮有效,停止按钮无效。
展开
展开全部
Private Sub Command1_Click()
Command2.Enabled = True
Command1.Enabled = False
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Command1.Enabled = True
Command2.Enabled = False
Timer1.Enabled = False
Image1.Top = 0
Image1.Left = 0
End Sub
Private Sub Form_Load()
Command2.Enabled = False
Timer1.Enabled = False
Timer1.Interval = 100
Image1.Top = 0
Image1.Left = 0
End Sub
Private Sub Timer1_Timer()
a = Image1.Top
b = Image1.Left
a = a + Form1.Height / 50
b = b + Form1.Width / 50
If a > Form1.Height Or b > Form1.Width Then
Command1.Enabled = True
Command2.Enabled = False
Timer1.Enabled = False
Image1.Top = 0
Image1.Left = 0
Else
Image1.Top = a
Image1.Left = b
End If
End Sub
Command2.Enabled = True
Command1.Enabled = False
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Command1.Enabled = True
Command2.Enabled = False
Timer1.Enabled = False
Image1.Top = 0
Image1.Left = 0
End Sub
Private Sub Form_Load()
Command2.Enabled = False
Timer1.Enabled = False
Timer1.Interval = 100
Image1.Top = 0
Image1.Left = 0
End Sub
Private Sub Timer1_Timer()
a = Image1.Top
b = Image1.Left
a = a + Form1.Height / 50
b = b + Form1.Width / 50
If a > Form1.Height Or b > Form1.Width Then
Command1.Enabled = True
Command2.Enabled = False
Timer1.Enabled = False
Image1.Top = 0
Image1.Left = 0
Else
Image1.Top = a
Image1.Left = b
End If
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-12-08
展开全部
这个很容易啊,程序如下:
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询