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

Text box VB Script display

zeBadWolf
1-Newbie

Text box VB Script display

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.

1 ACCEPTED SOLUTION

Accepted Solutions
RichardJ
19-Tanzanite
(To:zeBadWolf)

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.

View solution in original post

30 REPLIES 30

Hello!

Which version of Mathcad you use?

This version suits you (in PDF)?:

PDF_output.jpg

MikeArmstrong
5-Regular Member
(To:zeBadWolf)

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.

MikeArmstrong
5-Regular Member
(To:RichardJ)

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.

MikeArmstrong
5-Regular Member
(To:RichardJ)

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.

MikeArmstrong
5-Regular Member
(To:RichardJ)

That means it's a MS Forms 2.0 label. The property names were all defined by MS.

Got it, cheers.

Mike

I use Mathcad 14.0 M020 (14.0.2.5 [802141434]). Thank you for the attached mathCAD file and also I thank everyone for thier input, it worked perfectly.I kind of suspect it might be a bug given that our IT guys have to perfrorm a second install just to get the help menu to display correctly.
Once again, thanks alot!!!
MikeArmstrong
5-Regular Member
(To:zeBadWolf)

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.

MikeArmstrong
5-Regular Member
(To:zeBadWolf)

You could copy and paste it or follow the instructions below.

  • Insert component
  • Scriptable Object
  • Microsoft Forms Lable 2.0
  • Select JScript

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.

MikeArmstrong
5-Regular Member
(To:RichardJ)

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

RichardJ
19-Tanzanite
(To:zeBadWolf)

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

RichardJ
19-Tanzanite
(To:zeBadWolf)

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

RichardJ
19-Tanzanite
(To:zeBadWolf)

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.

RichardJ
19-Tanzanite
(To:zeBadWolf)

As Mike suggests, copying an existing example and modifying it is usually the easiest approach. There are a lot of examples here:

Extra Components.mcd

Thank you all, there are so many useful examples in that file. Stuff i didn't think mathcad was capable of doing.

MikeArmstrong
5-Regular Member
(To:zeBadWolf)

Attached are some additional functions written by Philip. Oakley

Mike

tietjee
14-Alexandrite
(To:zeBadWolf)

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

RichardJ
19-Tanzanite
(To:tietjee)

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?

tietjee
14-Alexandrite
(To:RichardJ)

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

RichardJ
19-Tanzanite
(To:tietjee)

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".

Top Tags