InvisibleApp.ConvertResult Method
Visio Automation Reference |
Converts a string or number into an equivalent number in different measurement units.
Version Information
Version Added: Visio 4.5
Syntax
expression.ConvertResult(StringOrNumber, UnitsIn, UnitsOut, lpr8Ret)
expression A variable that represents an InvisibleApp object.
Parameters
Name | Required/Optional | Data Type | Description |
---|---|---|---|
StringOrNumber | Required | Variant | String or number to be converted; can be a string, floating point number, or integer. |
UnitsIn | Required | Variant | Measurement units to attribute to StringOrNumber. |
UnitsOut | Required | Variant | Measurement units to express the result in. |
Return Value
Double
Remarks
If passed as a string, StringOrNumber might be the formula or prospective formula of a cell or the result or prospective result of a cell expressed as a string. The ConvertResult method evaluates the string and converts the result into the units designated by UnitsOut. The ConvertResult method returns an error if the string contains any cell references.
Possible values for StringOrNumber include:
1.7
3
"2.5"
"4.1 cm"
"12 ft - 17 in + (12 cm / SQRT(7))"
The UnitsIn and UnitsOut arguments can be strings such as "inches", "inch", "in.", or "i". Strings may be used for all supported Microsoft Office Visio units such as centimeters, meters, miles, and so on. You can also use any of the units constants declared by the Visio type library in VisUnitCodes. A list of valid units is also listed in About Units of Measure.
If StringOrNumber is a floating point number or integer, UnitsIn declares what unit of measure the ConvertResult method should construe the number to be. Pass "" to indicate internal Visio units.
If StringOrNumber is a string, UnitsIn specifies how to interpret the evaluated result and is only used if the result is a scalar. For example, the expression "4 * 5 cm" evaluates to 20 cm, which is not a scalar, so UnitsIn is ignored. The expression "4 * 5" evaluates to 20 which is a scalar and is interpreted using the specified UnitsIn.
The UnitsOut argument specifies in what units the returned number should be expressed. If you want the results expressed in the same units as the evaluated expression, pass "NOCAST" or visNoCast.
Examples where string is specified:
Visual Basic for Applications |
---|
|
Examples where number is specified:
Visual Basic for Applications |
---|
|
Example
The following macro shows how to use the ConvertResult method to report the distance between two shapes in centimeters, feet, yards, and miles. To run this macro, you must have two shapes selected on your page.
Visual Basic for Applications |
---|
|
See Also