×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Only selectable values for a given variable (pick from list)

 Forum Search FAQs Links MVPs

## Only selectable values for a given variable (pick from list)

(OP)
Hi folks!
I was wondering if its possible in Mathcad to eg. define a value for concrete compressive strenght fck, but instead of manualy entering values (like 20MPa,25MPa,30MPs...) I would only choose values from a some sort of list that pups-up when clicking in the "fck"=... value box.
Another thing, when you select a value of fck=30MPa is there any chance that MATHCAD automaticly uses value of modulus of elesticity coresponding to fck=30MPa.... Emodulus=30.000MPa?
Egsample, when you select a value for fck, a coresponding value for E would be automaticly choosen for later calculations...
fck=20MPa ---> E=25.000MPa
fck=25MPa ---> E=29.000MPa
fck=30MPa ---> E=31.000MPa

Thank you.

### RE: Only selectable values for a given variable (pick from list)

(OP)
Seems ok.
Is that fck "list box" collapsable or youll always see the whole list of available values?
How did you create it?

Can you explain a bit that small programing pice of how to choose E values for selected fck value.
Thanx a lot!

### RE: Only selectable values for a given variable (pick from list)

I don't understand why you cant just have the equation to calculate E after fck is define. A lot easier than a programming routine to do the exact same thing.

### RE: Only selectable values for a given variable (pick from list)

Sorry, should be all M[fck-1 in the "if"-statement.

### RE: Only selectable values for a given variable (pick from list)

In this case you add the ListBox over "Insert"-"Control" and "List Box". Then you right click on "Edit Script" and edit the "One", "Two" and "Three" characters and put in your own - or even add some more. I don't quite understand what you mean by "see the whole list of the available values" because in the original post you said: "select value for fck" - doesn't that mean they should all be there to be able to select?

### RE: Only selectable values for a given variable (pick from list)

(OP)
@struct
can you place an egsample...you mean to use a formula for calculating E based on fck value?
I did that but I want to use code specific values for E

@occupant
Thank you, will try and report back

### RE: Only selectable values for a given variable (pick from list)

I guess the attached file is what you are searching for. If you are willing to type in all the data in the component properties you may chose to use a Web Control. But I assume you have a bigger list of values to chose from and so in my version the Listbox entries are generated dynamically depending on a vector of force values and that way I had to use a scripted component. This means that on opening the file you will be asked if you want to disable scripting and have to click "No".

Concerning you question about all values being visible: Unfortunately there is no dropdown menu like component in Mathcad, at least not out of the box. The best we can use for this purpose are listboxes. But you can size those boxes so that only a limited number of entries are shown at once and you may scroll to get the rest, but the box will not expand dynamically when you click on it like a dropdown would do. To resize the component (I chose to see three entries out of the five or six I typed) you should first right click and chose "Show Arguments".

BTW, it may be a good idea to state which version of Mathcad you use when asking a question like this. If you would use Prime, the answer would have been much easier: No, you can't do that as we have no components in Prime.

@Occupant: I am not sure but is there any specific reason for posting pdf's rather than the real files? I guess a pdf is much less useful and if someone asks about Mathcad he sure is able to open a Mathcad document.

### RE: Only selectable values for a given variable (pick from list)

rmix22: That's really very simple, if somebody doesn't phraze their question with an accompanying Mathcad sheet, I do the same.

### RE: Only selectable values for a given variable (pick from list)

@Occupant: I understand and I consider it annyoing, too, if people ask and post pics or the like and assume others to retype. But in case of this question the worksheet wouldn't have helped other than at least showing which version the question is for - but then, we both assumed real Mathcad anyway

(OP)

### RE: Only selectable values for a given variable (pick from list)

#### Quote (mar2805)

Mathcad 14...sorry guys... smile
The sheet I posted was created with MC15[M030] but that should not be a problem for MC14.

### RE: Only selectable values for a given variable (pick from list)

(OP)
Guys sorry for the long delay I had a accident and broke my arm.
Anyway I tried to use what you have presented in .pdf files but I cant simulate even the most simpliest egsample.
In the file attched i made a listbox were I defined values for fck.
I can select the value from the list.
When I type fck anywhere in the sheet I get an value that reperesnts the row number and not the value thats defined in the list box ?!
How to change this?

Linking E value to this fck list box value now seems like science fiction to me
Can oyu explain how to do this and attach some egsample please.

### RE: Only selectable values for a given variable (pick from list)

The values displayed are string but you do not want the string as result I guess.

Did you look at the sheet I posted? Its not a pdf and it looks to me that it does what you want and you can define the values you want to be displayed for choice as a normal Mathcad vector and do not need to edit the script to change values.

### RE: Only selectable values for a given variable (pick from list)

(OP)
Yes Ive seen it but I would like to Know how it Works.
Dont get me wrong but I hate to copy something without any knowledge of how the thing works
If you where maybe kind enough to explain command you used it would be great couse I dont understand any of them :_(

### RE: Only selectable values for a given variable (pick from list)

(OP)
hmmmmmmm...made this...its primitive but it works nicely.
What do you think?

rmix22 how did you add that scroll bar on the right side?
Only problem now is that I dont know how to increase the font of that "select box"

### RE: Only selectable values for a given variable (pick from list)

I assume that the creation of fck_list and E_list as normal Mathcad vectors is clear.
Then I create a vector of strings consisting of the values of fck_list (numbers only, therefore divide by MPa) and added the string "MPa".
This string "name_list" is passed to the component as input, the output of the component is the index "sel" of the string which was selected. Depending on the value of "sel" f.ck and E are chosen from their appropriate vectors.
The component itself contains just a few VBS commands you may look at by right clicking the component and select "edit script".
I have put the creation creation of name_list and the assignments of f.ck and E in collapsed regions to put them out of the way.
For more information about VBS you may look up the appropriate help pages at the Microsoft site or all a lot of other ressources in the net. You have to keep in mind, though, that VBS (Visual Basic Script) is similar in some respects but not the same as pure VB or VBA (Visual Basic for Applications, the script languange in Excel, Word, ...).

### RE: Only selectable values for a given variable (pick from list)

(OP)
rmix22 thatx a lot.
Can you tell me plase how dod you mae that scroll bar in the control box?

### RE: Only selectable values for a given variable (pick from list)

If you size the box so that not all items fit in place it will come automatically if you have selected that you want it. You do so by right clicking the listbox, go to "Mathsoft ListBox Control-Object", chose "Properties" and in tab "General" activate "Vertical Scroll".

In my opinion its much harder to maintain a sheet if the items are hard coded in the VBScript. Thats the reason I prefer to pass it to the component as normal Mathcad vector. Code is much easier and transparent to manage that way an the component is reusable without any change (other than the names of the input and output variable). Furthermore its much easier to pick the value from a vector using the returned index as vector index (minus 1, if ORIGIN is 0) than to write the series of if statements.

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

#### Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!