VB代码窗体移动
VB加一个时钟控件由时钟控制使窗体从左移到右,当到达右边缘时,又从右移到左的如此反复代码怎么写?...
VB加一个时钟控件由时钟控制使窗体从左移到右,当到达右边缘时,又从右移到左的如此反复代码怎么写?
展开
2个回答
2014-05-17
展开全部
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
推荐于2018-04-11
展开全部
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
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询