Converting control name to control

Let's say i have a picturebox with the name "pic1"
I can get that controls name by doing

dim myControlName as string
myControlName = pic1.Name()

myControlName will now hold "pic1" as its string.

How do you do it the other way? I want to beable to pass in the string "pic1" and get the picturebox back.

is this possible?

thanks
[385 byte] By [stupidkid] at [2007-11-18 17:38:53]
# 1 Re: Converting control name to control
Hi,

you could use Me.pic1.GetType() to access the type of the element (here: pic1).

But please note that you won't get back the data as a string.

CU
Laques2000
Laques2000 at 2007-11-10 3:21:56 >
# 2 Re: Converting control name to control
Originally posted by DSJ
You'll have to loop thru the controls like:

Dim lb As Label
Dim ct As Control
Dim str As String = "label1"
For Each ct In Me.Controls
If ct.Name.ToUpper = str.ToUpper Then
lb = DirectCast(ct, Label)
MsgBox(lb.Text)
End If
Next
Craig Gemmill at 2007-11-10 3:22:56 >
# 3 Re: Converting control name to control
thank you very much, that was exactly what i was looking for!! :)
stupidkid at 2007-11-10 3:23:51 >