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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

MathCad 15, ListBox, VBscript, Array

nruhl
1-Visitor

MathCad 15, ListBox, VBscript, Array

Hi,  I haven't been using MathCad 15 very much and am relatively new to coding.

I'm having trouble using VBscript to get my List Box to do what I want it to do

In my MathCad file I've created a Matrix.  I then created an array that holds the first column of the matrix.  I want to feed that array into the ListBox to populate the List and then return the index of the selection from the listbox.

I can't seem to get the ListBox to populate with the Array.  I'm using ListBox.AddString () and keep getting the error "Type mismatch: 'ListBox.AddString'"

I'm not able to use the Array as I'd hoped

Please provide guidance, resources or tips

Thanks

ACCEPTED SOLUTION

Accepted Solutions

Hi

The documentation for the scripting language is not too helpful, the attached is a mix of items that I found on the forums and a little from trial & error.

The listbox that you scripted had a few issues.

Mainly that if you need to give it parameters, then the only place that I have seen to access the data is in the EXEC function not the START as you might expect.

the example has been modified to get it basically working, & has various changes in {ListBox Control} > properties to give scrollbars etc to ease the selection process.

It isn't a good example yet as it has at least one major flaw...

every time you access the control, it appends another complete set of your list at the end of the List box - it just keeps growing.

It doesn't allow for the control to 'remember' the selected state - so it needs to be set everytime the Mathcad sheet is opened.

I hope that this will get you started & no doubt will raise many more questions.

Regards

Andy

View solution in original post

6 REPLIES 6

Hi

The documentation for the scripting language is not too helpful, the attached is a mix of items that I found on the forums and a little from trial & error.

The listbox that you scripted had a few issues.

Mainly that if you need to give it parameters, then the only place that I have seen to access the data is in the EXEC function not the START as you might expect.

the example has been modified to get it basically working, & has various changes in {ListBox Control} > properties to give scrollbars etc to ease the selection process.

It isn't a good example yet as it has at least one major flaw...

every time you access the control, it appends another complete set of your list at the end of the List box - it just keeps growing.

It doesn't allow for the control to 'remember' the selected state - so it needs to be set everytime the Mathcad sheet is opened.

I hope that this will get you started & no doubt will raise many more questions.

Regards

Andy

Thank you for your response and comments. 

Raiko
17-Peridot
(To:nruhl)

Hello,

maybe this little code will help. BTY; there is a nice collection of codes and solutions called "Useful extra components" in this forum. Check for it, there may be more you maight find handy.

Raiko

nruhl
1-Visitor
(To:Raiko)

Thank you for the code and referenced information.

VladimirN
24-Ruby II
(To:Raiko)

Here is a link for "Extra Components and Controls" document: Extra Components and Controls

nruhl
1-Visitor
(To:VladimirN)

Thanks for posting the link

Announcements

Top Tags