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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

VB help!!

ptc-5654448
1-Visitor

VB help!!

Hi,

I'm a newbie here so please bear with me as I'm sure someone has already covered this topic but I can't find a thread anywhere.

In a nutshell, I want to get make a textbox to change colour dependent on what answer displayed in the box.

I've just completed the MathCAD 15 course and the instructor showed an example of this working, so I asked him how to do it. He told me it was al to do with the VB script running behind the text box and sent me the script.

When I tried to insert this into my own text box script it wouldn't work.

Adding it is not a problem (copy and paste) but the problem I’m having is trying to get the script to refer to the output of a previous calculation. I don’t quite understand how VB scripts work so I’m a bit lost as to where to add my references.

This is what I’ve tried so far….


insert+script.jpg

…but when I come out of the script, I get this message…

error.jpg

…I’m at a bit of a loss.

Can anyone suggest anything? Or is there any possibility that someone could show a simple example of how to write this script properly please?

Any help would be greatly appreciated!

9 REPLIES 9
Raiko
17-Peridot
(To:ptc-5654448)

Hello Hong Thoi,

within the VB Script Editor remove the quotation marks so that it reads

If utilisation.Value < 1 Then

instead of

If utilisation.Value "<1" Then

You've compared string with integer and VB doesn't like that.

Raiko

Hi Reiko,

Thanks for your reply.

I tried removing the quotation marks as you suggested like this...

insert+script+2.JPG

... but got a different error message instead...

error+2.JPG

any ideas? (sorry about my lack of VB knowledge, I thought this would be quite a simply script for me to start on...)

Try removing the = sign (the one after utilisation.Value) Or change it to <= rather than =<.

Alan

Werner_E
25-Diamond I
(To:ptc-5654448)

Write <= instead of = <

Hi guys,

I've tried swapping the < and = around like so...

insert+script+3.JPG

... but get the originall error message when I come out of the script editor...

error+3.JPG

... I'll bet whatever I'm doing wrong must be something simple. Just dont know what it is 😞

Werner_E
25-Diamond I
(To:ptc-5654448)

the names of the worksheet variables are not known in the VBScript, you have to passe the variable you want to check via Input variable.

Why don't you post the sheet instead of pics?

Hi Werner,

Good idea, I should have done that right at the beginning (doh!)

here it is...

Werner_E
25-Diamond I
(To:ptc-5654448)

Find attached two components (with hidden arguments - use right cick) which should do what you want.

The second is a modification of a label I simply copied from Richards fine collection http://communities.ptc.com/docs/DOC-1071

Thanks Wener

Much appreciated

Announcements

Top Tags