Example 4: MS Dev Studio VB.NET
This example is a VB.NET application that shows how to push data values with units to PTC Mathcad Prime, and how to retrieve results with units. Form1.vb contains callbacks that are responsible for the functionality. The Button1_Click (Calculate Stress) pulls the value and unit you typed into the VB form and sends it to the already running beamdef.mcdx worksheet. The Max Stress text box gets the return value, and the unit populates a label to the right of the text box. The Show Prime check box toggles the visibility of PTC Mathcad Prime.
2. To run the example, execute BeamDef.exe. The Beam Analysis application dialog window opens. All input fields are disabled.
3. Click > to open the beamdef.mcdx worksheet. The text fields are now enabled.
4. In the open worksheet, note the two regions designated as Input that contain the definitions of Beamlength and Force.
5. In the Beam Analysis dialog window, type a value in the Length of beam text box, and in the Load to place on beam text box.
6. Click Calculate Stress to send the data to the worksheet.
7. In the worksheet, watch the two input areas, Beamlength and Force, take on the values you specified in the Beam Analysis dialog window.
8. Scroll to the bottom of the worksheet and note the new value of Smax. This value is sent back to the Beam Analysis dialog window, and appears in the Max Stress field.
9. Click the Show Mathcad Prime check box to toggle the visibility of PTC Mathcad Prime.
10. Use the list boxes to select a different unit for Length of beam and/or Load to place on beam, then click Calculate Stress.
11. Repeat steps 7 and 8 and ensure the newly specified units are visible in the two input regions, and that the new value of Smax appears in the Max Stress field of the Beam Analysis dialog window. The value of Max Stress remains in units of Pa (Pascal).
12. Select different combinations of values and units and ensure that the calculation always returns a value for Max Stress.
13. In PTC Mathcad Prime, click > , and then in Beam Analysis dialog window click > .