想请教一下各位大神们这代码里的问题,想做出字幕碰到边缘会反弹的效果,可是到边缘就停住了
Dima%,b%,n%PrivateSubTimer1_Timer()Randomizea=Label1.Leftb=Label1.Topn=Int(Rnd*65+8)S...
Dim a%, b%, n%
Private Sub Timer1_Timer()
Randomize
a = Label1.Left
b = Label1.Top
n = Int(Rnd * 65 + 8)
Select Case b
Case Is = 0
Label1.Top = Label1.Top + 50
Label1.FontSize = n
Case Is = 3930
Label1.Top = Label1.Top - 50
Label1.FontSize = n
End Select
Select Case a
Case Is = 0
Label1.Left = Label1.Left + 50
Label1.FontSize = n
Case Is = 3090
Label1.Top = Label1.Left - 50
Label1.FontSize = n
End Select
End Sub
Private Sub Timer2_Timer()
a = Label1.Left
b = Label1.Top
n = Int(Rnd * 65 + 8)
Label1.Left = Label1.Left - 50
Label1.Top = Label1.Top - 50
If b = 0 Or b = 3930 Or a = 0 Or a = 3090 Then
Timer2.Enabled = False
End If
End Sub 展开
Private Sub Timer1_Timer()
Randomize
a = Label1.Left
b = Label1.Top
n = Int(Rnd * 65 + 8)
Select Case b
Case Is = 0
Label1.Top = Label1.Top + 50
Label1.FontSize = n
Case Is = 3930
Label1.Top = Label1.Top - 50
Label1.FontSize = n
End Select
Select Case a
Case Is = 0
Label1.Left = Label1.Left + 50
Label1.FontSize = n
Case Is = 3090
Label1.Top = Label1.Left - 50
Label1.FontSize = n
End Select
End Sub
Private Sub Timer2_Timer()
a = Label1.Left
b = Label1.Top
n = Int(Rnd * 65 + 8)
Label1.Left = Label1.Left - 50
Label1.Top = Label1.Top - 50
If b = 0 Or b = 3930 Or a = 0 Or a = 3090 Then
Timer2.Enabled = False
End If
End Sub 展开
1个回答
展开全部
Dim p%
Private Sub Timer1_Timer()
a = Label1.Left
b = Label1.Top
If a < 0 Or b < 0 Then p = 1
If a > 3090 Or b > 3090 Then p = 0
If p = 1 Then
Label1.Top = Label1.Top + 50
Label1.Left = Label1.Left + 50
Else
Label1.Top = Label1.Top - 50
Label1.Left = Label1.Left - 50
End If
End Sub
Private Sub Timer1_Timer()
a = Label1.Left
b = Label1.Top
If a < 0 Or b < 0 Then p = 1
If a > 3090 Or b > 3090 Then p = 0
If p = 1 Then
Label1.Top = Label1.Top + 50
Label1.Left = Label1.Left + 50
Else
Label1.Top = Label1.Top - 50
Label1.Left = Label1.Left - 50
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询