Dim
r,
l,
s
As
Boolean
Private
Sub
Form_Load()
s
=
True
l
=
False
r
=
False
End
Sub
Private
Sub
Timer1_Timer()
If
Image1.Left
<=
0
Or
r
=
True
Then
Image1.Left
=
Image1.Left
+
100
l
=
False
r
=
True
End
If
If
Form1.Width
-
Image1.Width
<=
Image1.Left
Or
l
=
True
Then
Image1.Left
=
Image1.Left
-
100
r
=
False
l
=
True
End
If
If
(Image1.Left
<>
0
Or
Form1.Width
-
Image1.Width
<=
Image1.Left)
And
s
=
True
Then
Image1.Left
=
Image1.Left
+
100
l
=
False
r
=
True
s
=
False
End
If
End
Sub
我调试过可达到你的要求
我在窗口上添加了image控件
和timer控件
timer1.interval=1
image1.stretch=true
Dim r, l, s As Boolean
Private Sub Form_Load()
s = True
l = False
r = False
End Sub
Private Sub Timer1_Timer()
If Image1.Left <= 0 Or r = True Then
Image1.Left = Image1.Left + 100
l = False
r = True
End If
If Form1.Width - Image1.Width <= Image1.Left Or l = True Then
Image1.Left = Image1.Left - 100
r = False
l = True
End If
If (Image1.Left <> 0 Or Form1.Width - Image1.Width <= Image1.Left) And s = True Then
Image1.Left = Image1.Left + 100
l = False
r = True
s = False
End If
End Sub
我调试过可达到你的要求
我在窗口上添加了image控件 和timer控件 timer1.interval=1 image1.stretch=true
Private Sub Form_Load()
Picture1.Left = Form1.Width - Picture1.Width
Timer1.Interval = 50
End Sub
Private Sub Timer1_Timer()
Picture1.Left = Picture1.Left - 100
If Picture1.Left < 0 Then
Picture1.Left = Form1.Width - Picture1.Width
End If
End Sub
还以为要左右晃呢,这次方向就对了