cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Passing variable to listbox

Raiko
17-Peridot

Passing variable to listbox

Hello,

In the attached sheet I feed an array into a list box. I wish to display only a certain column, therefore I also pass an index into the listbox.
It only works when within the code a constant is provided that determines the column index. Passing the varaible doesn't suffice.
Is ther something fundamentally wrong with my code or is this a MathCad quirk?

Thanks in advance

Raiko
4 REPLIES 4
RichardJ
19-Tanzanite
(To:Raiko)

It's a quirk. I've noticed quirks like this with the input values before. I always assign the inputs to variables, then use the variables in subsequent code. So if you add the line M=inputs(1).value and then use M in the loop it works.

Richard

Even if you make it work, the scripted component is a very poor tool. I would say useless vs the real projects generally encountered as it was the case for some "Image Explorer" done in this collab. What about shuffling and select a collection for the next part of the project ? Some scripted components are very useful at times, doing things Mathcad does not do naturally but if they are just band-aid, don't wound Mathcad first !

jmG
TomGutman
1-Visitor
(To:Raiko)

It's a data type issue. MC numeric data is always double precision floating point. The value property does not properly coerce a floating pint number used as an index into an integer, and so you get the failure. Richard's suggestion works because then you are using VBS subscripts, and they do properly convert. You can also just include an explicit CInt to fix the problem.
__________________
� � � � Tom Gutman
Raiko
17-Peridot
(To:TomGutman)

Thank you Tom - it works like charm!
That's the kind of advice I love - easy to do and even more important easy to understand

Raiko
Announcements

Top Tags