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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

MathCad 15, ListBox, VBscript, Array

nruhl
1-Newbie

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

1 ACCEPTED SOLUTION

Accepted Solutions
AndyWesterman
4-Participant
(To:nruhl)

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
AndyWesterman
4-Participant
(To:nruhl)

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
16-Pearl
(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-Newbie
(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

Thanks for posting the link

Top Tags