VB里怎么让字体左右自动移动啊,怎么改都没用,点自动跟点手动一样。。
PublicClassForm1Dimi=1PrivateSubForm_Load()Timer1.Enabled=TrueTimer1.Interval=100EndS...
Public Class Form1
Dim i = 1
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 100
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
Label1.Left = Label1.Left + 50 * i
If Label1.Left >= Width Then
i = i * -1
End If
If Label1.Left <= 0 Then
i = i * -1
End If
End Sub
Private Sub Timer1_Timer()
Label1.Left = Label1.Left + 50 * i
If Label1.Left >= Width Then
i = i * -1
End If
If Label1.Left <= 0 Then
i = i * -1
End If
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
Label1.Left = Label1.Left + 50 * i
If Label1.Left >= Width Then
i = i * -1
End If
If Label1.Left <= 0 Then
i = i * -1
End If
End Sub
End Class 展开
Dim i = 1
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 100
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
Label1.Left = Label1.Left + 50 * i
If Label1.Left >= Width Then
i = i * -1
End If
If Label1.Left <= 0 Then
i = i * -1
End If
End Sub
Private Sub Timer1_Timer()
Label1.Left = Label1.Left + 50 * i
If Label1.Left >= Width Then
i = i * -1
End If
If Label1.Left <= 0 Then
i = i * -1
End If
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
Label1.Left = Label1.Left + 50 * i
If Label1.Left >= Width Then
i = i * -1
End If
If Label1.Left <= 0 Then
i = i * -1
End If
End Sub
End Class 展开
1个回答
展开全部
给你提个思路,把下列代码复制到窗体代码窗口。
Private Sub Command1_Click()
If Me.Timer1.Enabled = True Then
Me.Timer1.Enabled = False
Else
Me.Timer1.Enabled = True
End If
End Sub
Private Sub Form_Load()
Me.Timer1.Interval = 100
Me.Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Me.Label1.Left = Me.Label1.Left + 100
If Me.Label1.Left >= 5000 Then
Me.Label1.Left = 100
End If
End Sub
Private Sub Command1_Click()
If Me.Timer1.Enabled = True Then
Me.Timer1.Enabled = False
Else
Me.Timer1.Enabled = True
End If
End Sub
Private Sub Form_Load()
Me.Timer1.Interval = 100
Me.Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Me.Label1.Left = Me.Label1.Left + 100
If Me.Label1.Left >= 5000 Then
Me.Label1.Left = 100
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询