Private Sub Command1_Click() If Command1.Caption = "左" Then If Label1.Left <= 0 Then Command1.Caption = "右" Else Label1.Left = Label1.Left - 120 End If ElseIf Command1.Caption = "右" Then If Label1.Left >= Form1.Width - Label1.Width Then Command1.Caption = "左" Else Label1.Left = Label1.Left + 120 End If End If End Sub 你试试吧,觉得移动慢就把数字改大点
Private Sub Command1_Click() If Command1Caption = "左" Then MoveLeft Else MoveRight End If End Sub '向左 Private Sub MoveLeft() With Label1 Do While (.Left + .Width) < Me.ScaleWidth .Left = .Left + 15 DoEvents Loop End With Command1.Caption = "右" End Sub '向右 Private Sub MoveRight() With Label1 Do While .Left > 0 .Left = .Left - 15 DoEvents Loop End With Command1.Caption = "左" End Sub
第2个回答 2014-04-21
按钮的代码
Private Sub Command1_Click() If Command1.Caption = "左" Then Label1.Left = Label1.Left - 50 If Label1.Left <= 10 Then Command1.Caption = "右" End If End If
If Command1.Caption = "右" Then Label1.Left = Label1.Left + 50 End If