Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
I wrote a VB script for a text box to highlight condition based on the input variable. However, when I print the mathcad file is doesn't display the color of the textbox. Is there a setting that I'm missing that is causing it to print incorrectly?
Attached a sample mathcad file that contains the script. I apologize in advance if this is a repost.
Any help is greatly appreciated, Thanks.
Solved! Go to Solution.
Is there a way to make the scripted label have a pre-defined width? E.g the width of the page.
Yes, although it's something of a pain to size the label, because you can't just drag it to the correct size.
In the script add a line
TextLabel.Caption="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
After the "End If". Make the text string long enough that the label is the size you want. Exit the script, select it, hit F9 to make sure it updates to the desired size. Now in the script remove that line, and set TextLabel.AutoSize = 0. It will now stay at that size. You may also want to add the line
TextLabel.TextAlign = 2
in the top section, which will center the text.
Hello!
Which version of Mathcad you use?
This version suits you (in PDF)?:
Please see attached. I have used a scripted Label component, which seems to work.
I have no idea why textboxes do not display when printing.
Mike
I have no idea why textboxes do not display when printing.
It looks like a bug to me.
When using the label scripted component the following command seems to be the line which makes the background visible when printing.
TextLabel.Caption = Inputs(3).Value
Textboxes do not support this function though.
Mike
The property just goes by a different name, whatever was chosen by the person that wrote the component. The equivalent is Textbox.Text.
The property just goes by a different name, whatever was chosen by the person that wrote the component. The equivalent is Textbox.Text.
Oh right. I wrote the component and it was based on one of the scripted objects found in your Extra Components document.
Mike
Oh right. I wrote the component and it was based on one of the scripted objects found in your Extra Components document.
That means it's a MS Forms 2.0 label. The property names were all defined by MS.
That means it's a MS Forms 2.0 label. The property names were all defined by MS.
Got it, cheers.
Mike
Once again, thanks alot!!!
No problem at all, it took me by surprise when it didn't work.
Mike
I have one last question; how do you insert a "scripted label" like the one in the mathcad file? I can't seen to find it.
Thank you.
You could copy and paste it or follow the instructions below.
Mike
- Select JScript
Whether you select VBscript or Jscript is up to you, but every example I have seen posted to the forums is in VBscript. So if you want to copy code from other examples, or expect any help, VBscript is the better choice.
Whether you select VBscript or Jscript is up to you, but every example I have seen posted to the forums is in VBscript. So if you want to copy code from other examples, or expect any help, VBscript is the better choice.
Opps, typo. Well spotted.
Mike
Is there a way to make the scripted label have a pre-defined width? E.g the width of the page. For my report summary, it will be neater and organized if all labels with their background corners had the same width.
I know I ask a lot of questions, however, please be patient with me as I'm still a rookie with VB Script and as such require your assistance.
Thanks
Is there a way to make the scripted label have a pre-defined width? E.g the width of the page.
Yes, although it's something of a pain to size the label, because you can't just drag it to the correct size.
In the script add a line
TextLabel.Caption="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
After the "End If". Make the text string long enough that the label is the size you want. Exit the script, select it, hit F9 to make sure it updates to the desired size. Now in the script remove that line, and set TextLabel.AutoSize = 0. It will now stay at that size. You may also want to add the line
TextLabel.TextAlign = 2
in the top section, which will center the text.
Worked perfectly!!!....
Is there a VB Script that can be written to make sure the input variable [Inputs(0).Value] is defined. I've run into the situation where there's an error stating "This variable is undefined", however my label still displays the results as correct which is quite misleading. i want to write a sciprt like
- If Inputs(0).Value = Defined Then.......
Any help is appreciated.
Thanks
If an input variable is undefined the script never executes, so there is nothing you can do in the script that will solve this problem.
Yes it doesn't execute, but it is displaying the most recent results. Kindly see attached mathcad file, I explained my question in a little bit more detail.
Thanks in advance
I understand your question. But the component exists in a given state until something in the script changes the state. And you can't make the script execute if there is an undefined variable on the input, which means you can't change it's state from "pass" to anything else.
Okay, I guess the only option i have is to review the calculations carefully. Thanks for the clarification.
As Mike suggests, copying an existing example and modifying it is usually the easiest approach. There are a lot of examples here:
Thank you all, there are so many useful examples in that file. Stuff i didn't think mathcad was capable of doing.
I downloaded the "Extra Components.mcd" to start the learning process on using VB. There two programs that caught my attention to help writing the reports. The first was eqnum which provided a method to count figures. The second was VarValue which set text. I would like to combine the two program so I can set the text in eqnum. I have tried several but got errors each time. I have attached a file with the two programs.
Thanks in advance for the support.
David Tg
It's not clear to me what you want when you say "combine them". Do you mean you want to able to set the text style in the caption?
I am able to add text to the caption. Running the VB results are:
Figure (1) This is the caption
Unfortunately, I would like the output to be in Times New Roman, 12 pt. It seems the second program is able to set the font. That is what I would like to combine from the second file.
Thanks,
David Tg
Unfortunately, I would like the output to be in Times New Roman, 12 pt. It seems the second program is able to set the font. That is what I would like to combine from the second file.
VarValue is based on an MS Forms 2.0 label, not a Mathsoft textbox. The properites of these objects are not part of VB, they are set by the developer of the object. So properties that are available in one may not be available in the other, and even if they are available they may not have the same name.
You can set the font of the Mathsoft textbox by right clicking, ansd selecting "Mathsoft textBox Control Object, Properties".