VB动态添加时间控件
VB动态添加控件Dimtimer1AsTimerPrivateSubForm_Load()Settimer1=Controls.Add("vb.timer","Timer...
VB动态添加控件
Dim timer1 As Timer
Private Sub Form_Load()
Set timer1 = Controls.Add("vb.timer", "Timer1")
timer1.Enabled = True
timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Timer
End Sub
上面的代码不要
Private WithEvents Timer1 As Timer
Private WithEvents Label1 As Label
Private Sub Form_Load()
Set Timer1 = Controls.Add("vb.timer", "Timer1")
Set Label1 = Controls.Add("VB.Label", "Label1")
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Time
End Sub 展开
Dim timer1 As Timer
Private Sub Form_Load()
Set timer1 = Controls.Add("vb.timer", "Timer1")
timer1.Enabled = True
timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Timer
End Sub
上面的代码不要
Private WithEvents Timer1 As Timer
Private WithEvents Label1 As Label
Private Sub Form_Load()
Set Timer1 = Controls.Add("vb.timer", "Timer1")
Set Label1 = Controls.Add("VB.Label", "Label1")
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Time
End Sub 展开
4个回答
展开全部
漏了一迅棚句:Label1.Visible = True
应该是搭瞎:
Private WithEvents Timer1 As Timer
Private WithEvents Label1 As Label
Private Sub Form_Load()
Set Timer1 = Controls.Add("vb.timer", "知昌空Timer1")
Set Label1 = Controls.Add("VB.Label", "Label1")
Timer1.Enabled = True
Timer1.Interval = 1000
Label1.Visible = True
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Time
End Sub
应该是搭瞎:
Private WithEvents Timer1 As Timer
Private WithEvents Label1 As Label
Private Sub Form_Load()
Set Timer1 = Controls.Add("vb.timer", "知昌空Timer1")
Set Label1 = Controls.Add("VB.Label", "Label1")
Timer1.Enabled = True
Timer1.Interval = 1000
Label1.Visible = True
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Time
End Sub
展开全部
Option Explicit
'添加一个label,其index属性设置成0
'扮扒添加一个timer,其index属性设置成0
'其余属性均按默认处理,然后粘察缺模败缓贴如下代码
Private Sub Form_Load()
Label1(0).Caption = ""
Dim i As Integer
For i = 1 To 3
Load Label1(i)
Load Timer1(i)
Label1(i).Caption = ""
Label1(i).Visible = True
Timer1(i).Interval = 100 * i
Timer1(i).Enabled = True
Label1(i).Top = i * 300
Label1(i).Left = 300
Label1(i).Height = 200
Next i
End Sub
Private Sub Timer1_Timer(Index As Integer)
Static x(1 To 3) As Long
x(Index) = x(Index) + 1
Label1(Index).Caption = x(Index)
End Sub
'添加一个label,其index属性设置成0
'扮扒添加一个timer,其index属性设置成0
'其余属性均按默认处理,然后粘察缺模败缓贴如下代码
Private Sub Form_Load()
Label1(0).Caption = ""
Dim i As Integer
For i = 1 To 3
Load Label1(i)
Load Timer1(i)
Label1(i).Caption = ""
Label1(i).Visible = True
Timer1(i).Interval = 100 * i
Timer1(i).Enabled = True
Label1(i).Top = i * 300
Label1(i).Left = 300
Label1(i).Height = 200
Next i
End Sub
Private Sub Timer1_Timer(Index As Integer)
Static x(1 To 3) As Long
x(Index) = x(Index) + 1
Label1(Index).Caption = x(Index)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼主,你派哪橘这controls.add在VB6里已经尘团不能使用了,VB5还可以。
在VB6中用Load动缓陵态载入控件,前提是先在窗体上加入控件数组。
在VB6中用Load动缓陵态载入控件,前提是先在窗体上加入控件数组。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
首先是流程(思路),然后才写程序。要养成好习惯。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询