Modify multiple text boxes with sub

swu

Active member
Joined
Mar 26, 2005
Messages
33
Programming Experience
1-3
I'm trying to modify multiple textboxes with a sub routine.

This is a rough snipet I was testing, how do I set an object current via code?

VB.NET:
sub tboxmod()

Dim n As Integer
Dim Tname As String
For n = 1 To 2
Tname = "TextBox" & n
Dim TBox As TextBox

Set TBox = Tname
TBox.Text = "n"

Next n

End Sub
THanks in advance
 
Last edited by a moderator:
Moved to Windows Forms forum, VS forum matters Visual Studio issues.

Use code box when you post code.

.Net 2.0 is so much more convenient, upgrade!
VB.NET:
Dim TBox As TextBox = Me.Controls(Tname)
With .Net 1.1 you have to check all controls to find the one with the Name you want, make yourself a function like this:
VB.NET:
function getcontrol(name as string) as control
for each c as control in me.controls
if c.name = name then return c
next
return nothing
end function
 
Back
Top