求用VB语言实现图片沿窗体移动的程序
写一个程序让图片沿窗体的四周做顺时针或逆时针运动,运行后手动改变窗体大小图片自动再贴着窗体移动,图片移动是顺时针还是逆时针用单选框控制,移动速度和步伐用两个滚条控制是做矩...
写一个程序让图片沿窗体的四周做顺时针或逆时针运动,运行后手动改变窗体大小图片自动再贴着窗体移动,图片移动是顺时针还是逆时针用单选框控制,移动速度和步伐用两个滚条控制
是做矩形运动~就是图片的边一直贴着最近的窗体的边 展开
是做矩形运动~就是图片的边一直贴着最近的窗体的边 展开
3个回答
展开全部
Dim PicMove1 As Integer
Private Sub Form_Load()
Picture1.Top = 0
Picture1.Left = 0
HScroll1.Min = 1
HScroll1.Max = 10
HScroll1.Value = 1
HScroll2.Min = 50
HScroll2.Max = 5000
HScroll2.Value = 500
Option1.Value = True
Timer1.Interval = HScroll2.Value
End Sub
Private Sub HScroll2_Change()
Timer1.Interval = HScroll2.Value
End Sub
Private Sub Timer1_Timer()
With Picture1
If Option1.Value = True Then
Select Case PicMove1
Case 0
.Top = .Top + HScroll1.Value * 15
If .Top >= Me.Height - .Height - 510 Then
.Top = Me.Height - .Height - 510
PicMove1 = 1
End If
Case 1
.Left = .Left + HScroll1.Value * 15
If .Left >= Me.Width - .Width - 150 Then
.Left = Me.Width - .Width - 150
PicMove1 = 2
End If
Case 2
.Top = .Top - HScroll1.Value * 15
If .Top <= 0 Then
.Top = 0
PicMove1 = 3
End If
Case 3
.Left = .Left - HScroll1.Value * 15
If .Left <= 0 Then
.Left = 0
PicMove1 = 0
End If
End Select
ElseIf Option2.Value = True Then
Select Case PicMove1
Case 1
.Top = .Top + HScroll1.Value * 15
If .Top >= Me.Height - .Height - 510 Then
.Top = Me.Height - .Height - 510
PicMove1 = 2
End If
Case 0
.Left = .Left + HScroll1.Value * 15
If .Left >= Me.Width - .Width - 150 Then
.Left = Me.Width - .Width - 150
PicMove1 = 1
End If
Case 3
.Top = .Top - HScroll1.Value * 15
If .Top <= 0 Then
.Top = 0
PicMove1 = 0
End If
Case 2
.Left = .Left - HScroll1.Value * 15
If .Left <= 0 Then
.Left = 0
PicMove1 = 3
End If
End Select
End If
End With
End Sub
Private Sub Form_Load()
Picture1.Top = 0
Picture1.Left = 0
HScroll1.Min = 1
HScroll1.Max = 10
HScroll1.Value = 1
HScroll2.Min = 50
HScroll2.Max = 5000
HScroll2.Value = 500
Option1.Value = True
Timer1.Interval = HScroll2.Value
End Sub
Private Sub HScroll2_Change()
Timer1.Interval = HScroll2.Value
End Sub
Private Sub Timer1_Timer()
With Picture1
If Option1.Value = True Then
Select Case PicMove1
Case 0
.Top = .Top + HScroll1.Value * 15
If .Top >= Me.Height - .Height - 510 Then
.Top = Me.Height - .Height - 510
PicMove1 = 1
End If
Case 1
.Left = .Left + HScroll1.Value * 15
If .Left >= Me.Width - .Width - 150 Then
.Left = Me.Width - .Width - 150
PicMove1 = 2
End If
Case 2
.Top = .Top - HScroll1.Value * 15
If .Top <= 0 Then
.Top = 0
PicMove1 = 3
End If
Case 3
.Left = .Left - HScroll1.Value * 15
If .Left <= 0 Then
.Left = 0
PicMove1 = 0
End If
End Select
ElseIf Option2.Value = True Then
Select Case PicMove1
Case 1
.Top = .Top + HScroll1.Value * 15
If .Top >= Me.Height - .Height - 510 Then
.Top = Me.Height - .Height - 510
PicMove1 = 2
End If
Case 0
.Left = .Left + HScroll1.Value * 15
If .Left >= Me.Width - .Width - 150 Then
.Left = Me.Width - .Width - 150
PicMove1 = 1
End If
Case 3
.Top = .Top - HScroll1.Value * 15
If .Top <= 0 Then
.Top = 0
PicMove1 = 0
End If
Case 2
.Left = .Left - HScroll1.Value * 15
If .Left <= 0 Then
.Left = 0
PicMove1 = 3
End If
End Select
End If
End With
End Sub
展开全部
这个程序很简单,但代码较多哟..原理就是首先看图片框在窗体的哪一个位置,如果在左边,那看是在上左还是下左,如果在上左就向下走(根据单选框来)向下走就是增加TOP值,如果到底了,就向右移,到最右了就向上移..
很简单的,你自己多试试啊...没什么技术含量!
很简单的,你自己多试试啊...没什么技术含量!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
做矩形运动?还是做圆周啊?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询