Home All Groups Group Topic Archive Search About

refrence a form object using a varible.

Author
29 Sep 2006 4:15 AM
xnakxx
for the sake of making my crazy question eaiser to understand i will
try to simplify it as much as possible.

Let's say I have a form with one textbox (txtname) and one button
(bntGo). How would i go about changing the "text" attribute of the
textbox using the var "name"?
I am sure that this is a noob question. but then agian i am a noob to
VB.Net. I have tried many searches but i guess i have not been able to
state my question good enough for google.

<bad syntax I know>
dim name as string = "txtName"


Private Sub btnG0_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

name.text = "xnakx"

End Sub
</bad syntax I know>

Author
29 Sep 2006 10:26 AM
teslar91
This does what you want:

Me.Controls(name).Text = "xnakx"