Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Noob question about creating txtbox control

Status
Not open for further replies.

simian336

Programmer
Sep 16, 2009
723
US
ok... I have a row of txtboxes and if the use hits a new row button I want to create a new row of txt boxes. So I want to pass name and number to a procedure and have it create the a new txt box.

Private Sub addtextbox(ByVal xday As String, ByVal xnum As Integer)

Dim MyNewControlName As String
MyNewControlName = xday + Trim(Str(xnum))

Dim MyNewControlName As New TextBox
Dim myloc As New System.Drawing.Point(200,200)
With MyNewControlName
.Text = "test"
.Location = myloc
End With
Me.Controls.Add(MyNewControlName)
Me.Refresh()

End Sub

So I need the name of the new txtbox to be named what is contained in the variable MyNewControlName.

Thanks

Simi

 
Changes to do what you want are in red.

Private Sub addtextbox(ByVal xday As String, ByVal xnum As Integer)

Dim MyNewControlName As String
MyNewControlName = xday + Trim(Str(xnum))

[red]Dim MyNewTextBox As New TextBox[/red]
Dim myloc As New System.Drawing.Point(200,200)
With [red]MyNewTextBox[/red]
.Text = "test"
.Location = myloc
[red].Name = MyNewControlName[/red]
End With
Me.Controls.Add(MyNewControlName)
Me.Refresh()

End Sub


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top