vb的小球运动
答案:1 悬赏:70 手机版
解决时间 2021-03-01 01:59
- 提问者网友:山高云阔
- 2021-02-28 01:30
vb的小球运动
最佳答案
- 五星知识达人网友:爱难随人意
- 2021-02-28 02:38
新建工程,1个timer1,1个shape,代码如下:
Dim i%
Private Sub Form_Load()
With Shape1
.Shape = 3
.BackColor = vbRed
.BackStyle = 1
.Height = 500
.Width = 500
End With
i = 0
Timer1.Enabled = True
Timer1.Interval = 30
End Sub
Private Sub Timer1_Timer()
If i = 0 Then
Shape1.Left = Shape1.Left + 20
If Shape1.Left = Me.ScaleWidth - Shape1.Width Then i = 1
ElseIf i = 1 Then
Shape1.Left = Shape1.Left - 20
If Shape1.Left = 0 Then i = 0
End If
End Sub
Dim i%
Private Sub Form_Load()
With Shape1
.Shape = 3
.BackColor = vbRed
.BackStyle = 1
.Height = 500
.Width = 500
End With
i = 0
Timer1.Enabled = True
Timer1.Interval = 30
End Sub
Private Sub Timer1_Timer()
If i = 0 Then
Shape1.Left = Shape1.Left + 20
If Shape1.Left = Me.ScaleWidth - Shape1.Width Then i = 1
ElseIf i = 1 Then
Shape1.Left = Shape1.Left - 20
If Shape1.Left = 0 Then i = 0
End If
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯