VB动态添加控件的问题——TextBox文本框
PrivateSubCommand1_Click()DimaAsLabelDimiAsIntegerFori=0To9Seta=Form1.Controls.Add("V...
Private Sub Command1_Click()
Dim a As Label
Dim i As Integer
For i = 0 To 9
Set a = Form1.Controls.Add("VB.TextBox", "Text" & i)
a.Visible = True
a.Move i * 500, i * 400, 1000, 300
a.BackColor = RGB(255, 255, 255)
a.Caption = "Text" & i
Next
Lab.Caption = "动态添加控件成功"
End Sub
哪位高手看看,这个程序错在哪里啦,我都郁闷了,,谢谢啦! 展开
Dim a As Label
Dim i As Integer
For i = 0 To 9
Set a = Form1.Controls.Add("VB.TextBox", "Text" & i)
a.Visible = True
a.Move i * 500, i * 400, 1000, 300
a.BackColor = RGB(255, 255, 255)
a.Caption = "Text" & i
Next
Lab.Caption = "动态添加控件成功"
End Sub
哪位高手看看,这个程序错在哪里啦,我都郁闷了,,谢谢啦! 展开
4个回答
展开全部
Private Sub Command1_Click()
Dim a As TextBox
Dim i As Integer
For i = 0 To 9
Set a = Form1.Controls.Add("VB.TextBox", "Text" & i)
a.Visible = True
a.Move i * 500, i * 400, 1000, 300
a.BackColor = RGB(255, 255, 255)
a.Text = "Text" & i
Next
Lab.Caption = "动态添加控件成功"
End Sub
Dim a As TextBox
Dim i As Integer
For i = 0 To 9
Set a = Form1.Controls.Add("VB.TextBox", "Text" & i)
a.Visible = True
a.Move i * 500, i * 400, 1000, 300
a.BackColor = RGB(255, 255, 255)
a.Text = "Text" & i
Next
Lab.Caption = "动态添加控件成功"
End Sub
展开全部
Private Sub Command1_Click()
Dim a As TextBox
Dim i As Integer
For i = 0 To 9
Set a = Form1.Controls.Add("VB.TextBox", "Text" & i)
a.Visible = True
a.Move i * 500, i * 400, 1000, 300
a.BackColor = RGB(255, 255, 255)
a.Text = "Text" & i
Next
MsgBox "动态添加控件成功"
End Sub
Dim a As TextBox
Dim i As Integer
For i = 0 To 9
Set a = Form1.Controls.Add("VB.TextBox", "Text" & i)
a.Visible = True
a.Move i * 500, i * 400, 1000, 300
a.BackColor = RGB(255, 255, 255)
a.Text = "Text" & i
Next
MsgBox "动态添加控件成功"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1. 首先,你是动态添加textbox文本框的,那么你Dim a As Label肯定类型不匹配,可以直接Dim a
2. textbox文本框没有Caption属性,只有text属性
修改这两处后,可以执行了
2. textbox文本框没有Caption属性,只有text属性
修改这两处后,可以执行了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim a As textbox
a.text = "text" & i
a.text = "text" & i
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询