Convert myObject.Parameter to string "myObject.Parameter"

  • Thread starter Thread starter Nemisis
  • Start date Start date
N

Nemisis

Hi,

Is it possible to pass in an object and parameter into a function and
return it as a string.

i.e.

To make a call to the function i would put the following

Dim str as String = MyTestFunction(myObject.Parameter)

str should equal "myObject.Parameter"

if myObject was of type myObj, then str should return "myObj.Parameter"

Thanks
 
Hello, Nemisis!

What type has myObj.Property?

IMO to accomplish what you want you have to pass
to MyTestFunction not only propery value, but the whole type.

N> Hi,

N> Is it possible to pass in an object and parameter into a function and
N> return it as a string.

N> i.e.

N> To make a call to the function i would put the following

N> Dim str as String = MyTestFunction(myObject.Parameter)

N> str should equal "myObject.Parameter"

N> if myObject was of type myObj, then str should return
N> "myObj.Parameter"

N> Thanks


--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Vadym said:
Hello, Nemisis!

What type has myObj.Property?

IMO to accomplish what you want you have to pass
to MyTestFunction not only propery value, but the whole type.

Vad,

Maybe i have not explained to well. If i run the code below, what code
would i need in the function.

Dim A As Company = Company.GetCompany(6) ' 6 is the Id of the
company

Dim str as String = ReturnClassAndPropertyAsString(A.Name)

str should be equal to "Company.Name".

I believe i would have to use reflection for this? but i am not sure
if maybe there is a simpler solution that i do not know about.
 
Back
Top