Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

record type

Status
Not open for further replies.

geethanandh

Programmer
Jun 5, 2002
21
US
hello
I have created auserdefined variable say test
Type test
a as string
b as integer
end type

Now creating an array of it by saying
Dim sample(10) as test
Now i have two text boxes t1 and t2. T1 has the array index say 5 and T2 has the name of the element of the type (a or b)
What i want is the value of userdefined element based on the t1 and t2 values.

sample(5).b will retrieve the value of b in the 5th array element of sample.
since i am getting 5 and b from the text box if i give
sample(t1.text).(t2.text) its not returning any value.

Pls help me in this

bye
 
Hi,

It seems to me that this is a confusion between 'run time' and 'design time'

e.g sample(t1.text).(t2.text)

The compiler can 'interpret' that t1.text wil be set at run time.
however I think the compiler will struggle with interpreting t2.text into a property name or method event though its runtime value is set to 'a' or 'b'

In other words I don't think you can dynamically access the members of an object in this fashion! maybe an alternative, less elegant I know ;-) would be

if t2.text = "a" then
sample(t1.text).a
etc
(maybe it works for this trivial example!)

Hope this helps

Matt


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top