Private Sub Command1_Click() Dim MyLabel As Label Dim MyText As TextBox Set MyLabel = Controls.Add("VB.Label", "MyLabel") MyLabel.Caption = "MyLabel" MyLabel.Visible = True
Set MyText = Controls.Add("VB.TextBox", "MyText") MyText.Text = "MyText" MyText.Top = MyLabel.Height MyText.Visible = True End Sub
For I = 0 To x_Rs_1.RecordCount - 1 SSTab3.TabCaption(I) = x_Rs_1.Fields(1).Value '部門名稱 SSTab3.Tab = I If I > 0 Then Load RText1(I) Load RText2(I) End If RText2(I).Text = x_Rs_1.Fields(0).Value '部門代碼 RText1(I).Visible = True RText2(I).Visible = False Set RText1(I).Container = SSTab3 Set RText2(I).Container = SSTab3 RText1(I).Move 60, 360, 3765, 1185 RText2(I).Move 60, 360, 3765, 1185 x_Rs_1.MoveNext Next 這么詳細了.
Dim MyLabel As Label
Dim MyText As TextBox
Set MyLabel = Controls.Add("VB.Label", "MyLabel")
MyLabel.Caption = "MyLabel"
MyLabel.Visible = True
Set MyText = Controls.Add("VB.TextBox", "MyText")
MyText.Text = "MyText"
MyText.Top = MyLabel.Height
MyText.Visible = True
End Sub
比如添加了一个控件 M(0)
运行的时候 Load M(1) 就增加了一个,可以这么调用 M(1).Caption="新控件"
SSTab3.TabCaption(I) = x_Rs_1.Fields(1).Value '部門名稱
SSTab3.Tab = I
If I > 0 Then
Load RText1(I)
Load RText2(I)
End If
RText2(I).Text = x_Rs_1.Fields(0).Value '部門代碼
RText1(I).Visible = True
RText2(I).Visible = False
Set RText1(I).Container = SSTab3
Set RText2(I).Container = SSTab3
RText1(I).Move 60, 360, 3765, 1185
RText2(I).Move 60, 360, 3765, 1185
x_Rs_1.MoveNext
Next
這么詳細了.