Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

How to get the value of a property whose name is a computed string?

I have an indexed set of named properties, such as X1, X2, X3, etc, and I want to get the right one when I have 1, 2, or 3.  I can easily create a string "X2" from that.  So I need to do something like

me.properties("X2").value.  But that doesn't work (it is returning 0, and not throwing an error).  What is the right incantation here?

4 REPLIES
Solution
Solution
Accepted by topic author jgg
‎11-23-2016 03:42 PM

Re: How to get the value of a property whose name is a computed string?

Here is an example:

Automobile PartFamily

Property X1 = "Audi"

Property X2 = GetValueFrom(Me, "X1")

 

In custom.vb have a function like:

public Function GetValueFrom(p as obj, prop as string) as string

   return p.Properties(prop).Value

End Function

 

Hope this helps and answers your question.

 

Thanks,

-Thilak Rao

Re: How to get the value of a property whose name is a computed string?

To all: It turns out me.Foo.Bar is equivalent to me.Foo.Properties("Bar").Value, which is what I thought and Thilak put into his function.  The reason it wasn't working for me before was that I had a "bad foo".  That is, the error was in the object being accessed (it was a connection).

Re: How to get the value of a property whose name is a computed string?

Just to clarify - I don't think you can do this inside RS Architect

Me.Foo."Bar" (Since you have "Bar" as a string"). Of course this is valid Me.Foo.Bar.

Re: How to get the value of a property whose name is a computed string?

All works fine for me.

 

 

The code:

 

	Dim text_str As String = "The value of property " & Input_String & " is " & Me.Properties(Me.Input_String).Value
	msgbox(text_str)	

 

 

1.JPG2.JPG

 

 

Probably you need to verify your syntax, references, datatypes.