Anyone please give an idea on how to create text box & label control during run time... Anyone pls..

plz check this.

thanks a lot for the help......

Hi,
Please find the code below to create VB Controls/Array of Controls Dynamically

Dim ControlArrayCOunt As Integer
Dim txtControlArray() As TextBox
Private Sub Create_Control()
On Error GoTo a

Dim txtControl As TextBox
Set txtControl = Controls.Add("VB.TextBox", "txtControl")
txtControl.Top = 300
txtControl.Left = 200
txtControl.Visible = True
Exit Sub

a:


End Sub

Private Sub Create_ControlArray()
On Error GoTo a

ReDim txtControlArray(ControlArrayCOunt)

Set txtControlArray(ControlArrayCOunt - 1) = Controls.Add("VB.TextBox", "txtControl" & ControlArrayCOunt)
txtControlArray(ControlArrayCOunt - 1).Text = "TextBox" & ControlArrayCOunt
txtControlArray(ControlArrayCOunt - 1).Top = 300 + (ControlArrayCOunt * 400)
txtControlArray(ControlArrayCOunt - 1).Left = 300
txtControlArray(ControlArrayCOunt - 1).Visible = True
Exit Sub

a:
End Sub
'Command Button to create Control Once Dynamically
Private Sub Command1_Click()
Call Create_Control
End Sub
'Command Button to create Control array Dynamically
Private Sub Command2_Click()
ControlArrayCOunt = ControlArrayCOunt + 1
Call Create_ControlArray
End Sub

plz mark solved the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.