vb中标签向右移动的代码,运行怎么不动?求助!!!

来源:百度知道 编辑:UC知道 时间:2024/05/24 06:45:33
代码如下:
Private Sub Timer1_Timer()

If Label1.Width < 7995 Then
Label1.Width = Label1.Width + 100
Else
Label1.Width = Label1.Width - 3795

End If

End Sub

Width是宽度,移动的话用left属性
比如Private Sub Timer1_Timer()

If Label1.Width < 7995 Then
Label1.Width = Label1.Width + 100
Else
Label1.Width = Label1.Width - 3795

End If

End Sub

可以修改为

Private Sub Timer1_Timer()

If Label1.Left< 7995 Then
Label1.Left = Label1.Left + 100
Else
Label1.Left = Label1.Left - 3795

End If

End Sub

width是控件的宽度,left是该控件距离外边框(比如窗体,或者图片框等)的距离,所以要用left属性