VB中怎样使label在窗体内由上而下碰到窗体底部时再向上,如此往复移动,怎么写代码
PrivateSubCommand1_Click()Timer1.Interval=500CallmymoveEndSubSubmymove()Label1.MoveLa...
Private Sub Command1_Click()
Timer1.Interval = 500
Call mymove
End Sub
Sub mymove()
Label1.Move Label1.Left, Label1.Top + 100
If Label1.Top > Form1.Height Then Label1.Top = Label1.Top - 100
End Sub
Private Sub Command2_Click()
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
Call mymove
End Sub
这样写哪里错了 展开
Timer1.Interval = 500
Call mymove
End Sub
Sub mymove()
Label1.Move Label1.Left, Label1.Top + 100
If Label1.Top > Form1.Height Then Label1.Top = Label1.Top - 100
End Sub
Private Sub Command2_Click()
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
Call mymove
End Sub
这样写哪里错了 展开
展开全部
跟我下面的代码比较一下有什么不一样
Dim Bj As Boolean, Sz As Integer
Private Sub Command1_Click()
Timer1.Interval = 500
Call mymove
End Sub
Sub mymove()
Label1.Move Label1.Left, Label1.Top + 100 * Sz
If Label1.Top + Label1.Height > Form1.Height Then
Sz = -1
ElseIf Label1.Top < 0 Then
Sz = 1
End If
End Sub
Private Sub Command2_Click()
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
Call mymove
End Sub
Private Sub Form_Load()
Sz = 1
End Sub
Dim Bj As Boolean, Sz As Integer
Private Sub Command1_Click()
Timer1.Interval = 500
Call mymove
End Sub
Sub mymove()
Label1.Move Label1.Left, Label1.Top + 100 * Sz
If Label1.Top + Label1.Height > Form1.Height Then
Sz = -1
ElseIf Label1.Top < 0 Then
Sz = 1
End If
End Sub
Private Sub Command2_Click()
Timer1.Interval = 500
End Sub
Private Sub Timer1_Timer()
Call mymove
End Sub
Private Sub Form_Load()
Sz = 1
End Sub
展开全部
Dim X As Integer
Private Sub Command1_Click()
'下移
X = 0
End Sub
Private Sub Command2_Click()
'上移
X = 1
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 100
X = 0
End Sub
Private Sub Timer1_Timer()
If X = 0 Then
Label1.Top = Label1.Top + 200
If Label1.Top >= Me.Height - 3 * Label1.Height Then X = 1
Else
Label1.Top = Label1.Top - 200
If Label1.Top <= 0 Then X = 0
End If
End Sub
Private Sub Command1_Click()
'下移
X = 0
End Sub
Private Sub Command2_Click()
'上移
X = 1
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 100
X = 0
End Sub
Private Sub Timer1_Timer()
If X = 0 Then
Label1.Top = Label1.Top + 200
If Label1.Top >= Me.Height - 3 * Label1.Height Then X = 1
Else
Label1.Top = Label1.Top - 200
If Label1.Top <= 0 Then X = 0
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Timer1.Interval = 100
Timer2.Interval = 100
Call mymove
End Sub
Sub mymove()
Timer1.Enabled = True
Timer2.Enabled = False
Label1.Move Label1.Left, Label1.Top + 100
If Label1.Top > Form1.Height Then Call mymove1
End Sub
Sub mymove1()
Timer1.Enabled = False
Timer2.Enabled = True
Label1.Move Label1.Left, Label1.Top - 100
If Label1.Top < 0 Then Call mymove
End Sub
Private Sub Timer1_Timer()
Call mymove
End Sub
Private Sub Timer2_Timer()
Call mymove1
End Sub
Timer1.Interval = 100
Timer2.Interval = 100
Call mymove
End Sub
Sub mymove()
Timer1.Enabled = True
Timer2.Enabled = False
Label1.Move Label1.Left, Label1.Top + 100
If Label1.Top > Form1.Height Then Call mymove1
End Sub
Sub mymove1()
Timer1.Enabled = False
Timer2.Enabled = True
Label1.Move Label1.Left, Label1.Top - 100
If Label1.Top < 0 Then Call mymove
End Sub
Private Sub Timer1_Timer()
Call mymove
End Sub
Private Sub Timer2_Timer()
Call mymove1
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询