By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,626 Members | 1,653 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,626 IT Pros & Developers. It's quick & easy.

convert name of object into object itself

P: n/a
i have a class with a great number of private properties ...

the class contains various functions that accept as a parameter the name of
one of the private properties. the functions perform various operations on
the current value of the property ...

in the function's internal code, i'd like to obtain the value of the
relevant property without doing a lengthy

Select pParameterName
Case "MyParam1"
ParameterValue = mMyParam1
etc.

does .NET provide a mechanism to convert a string giving the name of an
object into the object itself?
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi John,

Strange patterns occur sometimes. The same question but from a different
viewpoint appears only minutes apart from yours. So the same answer for both!
;-)

Have a look and see if CallByName is of any use to you.

If that's not suitable, the next to look at is the Type class. (use
GetType on the object which owns the method/member that you are interested.
This has GetField/GetFields and GetMember/s which may do the job.

Regards,
Fergus
Nov 20 '05 #2

P: n/a
* "Fergus Cooney" <fi*****@post.com> scripsit:
Have a look and see if CallByName is of any use to you.


'CallByName' won't work on private members.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

P: n/a
How does one programmatically determine the type of an object, such as a
control ... ?

If MyControl.GetType() = HTMLControls.HTMLSelect Then

doesn't work ...

nor does

If MyControl.GetType() Is HTMLControls.HTMLSelect Then


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ej*************@TK2MSFTNGP11.phx.gbl...
* "Fergus Cooney" <fi*****@post.com> scripsit:
Have a look and see if CallByName is of any use to you.


'CallByName' won't work on private members.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Nov 20 '05 #4

P: n/a
"John A Grandy" <johnagrandy-at-yahoo.com> schrieb
How does one programmatically determine the type of an object, such
as a control ... ?

If MyControl.GetType() = HTMLControls.HTMLSelect Then

doesn't work ...

nor does

If MyControl.GetType() Is HTMLControls.HTMLSelect Then


If TypeOf MyControl Is HTMLControls.HTMLSelect

--
Armin

http://learn.to/quote

Nov 20 '05 #5

P: n/a
Hi John,

And the other way is long-winded:
If MyControl.GetType() Is GetType (HTMLControls.HTMLSelect) Then

So you were on the right lines but they were crossed. ;-)

With Armin's version I usually use TypeOf (MyControl) as it looks more
like a function.

Regards,
Fergus
Nov 20 '05 #6

P: n/a
* "John A Grandy" <johnagrandy-at-yahoo.com> scripsit:
How does one programmatically determine the type of an object, such as a
control ... ?

If MyControl.GetType() = HTMLControls.HTMLSelect Then


\\\
If TypeOf MyControl Is HTMLControls.HTMLSelect Then
...
End If
///

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.