VB代码窗体移动
答案:2 悬赏:20 手机版
解决时间 2021-04-01 01:39
- 提问者网友:人生佛魔见
- 2021-03-31 00:43
VB代码窗体移动
最佳答案
- 五星知识达人网友:琴狂剑也妄
- 2021-03-31 01:32
Dim aPrivate Sub Form_Load()
Timer1.Interval = 200
Timer1.Enabled = True
a = 300
End SubPrivate Sub Timer1_Timer()
Me.Left = Me.Left + a
If Me.Left + Me.Width >= Screen.Width Or Me.Left <= 0 Then a = -a
End Sub
Timer1.Interval = 200
Timer1.Enabled = True
a = 300
End SubPrivate Sub Timer1_Timer()
Me.Left = Me.Left + a
If Me.Left + Me.Width >= Screen.Width Or Me.Left <= 0 Then a = -a
End Sub
全部回答
- 1楼网友:上分大魔王
- 2021-03-31 02:02
Private Sub Form_Load()
Command1.Left = 0 '初始化要移动的控件,此处以command1控件为例
Command1.Top = 0
Timer1.Interval = 50 '指定移动时间间隔
End SubPrivate Sub Timer1_Timer()
If Command1.Left >= Me.Width - Command1.Width Then
Command1.Left = 0
End If
Command1.Left = Command1.Left + 200 '移动距离
End Sub
Command1.Left = 0 '初始化要移动的控件,此处以command1控件为例
Command1.Top = 0
Timer1.Interval = 50 '指定移动时间间隔
End SubPrivate Sub Timer1_Timer()
If Command1.Left >= Me.Width - Command1.Width Then
Command1.Left = 0
End If
Command1.Left = Command1.Left + 200 '移动距离
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯