Share via


Application.FormatResultEx Method

Visio Automation Reference

Formats a string or number into a string according to a format picture, using specified units for scaling and formatting. Optionally, for date or time strings, sets the language and calendar type of the string.

Version Information
 Version Added:  Visio 2003

Syntax

expression.FormatResultEx(StringOrNumber, UnitsIn, UnitsOut, Format, LangID, CalendarID)

expression   A variable that represents an Application object.

Parameters

Name Required/Optional Data Type Description
StringOrNumber Required Variant String or number to be formatted; can be passed as 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.
Format Required String Picture of what the result string should look like.
LangID Optional Long The language to use for the result string.
CalendarID Optional Long he calendar to use for the result string. The default value is the Western calendar, visCalWestern.

Return Value
String

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 FormatResultEx method evaluates the string and formats the result. Because the string is being evaluated outside the context of being the formula of a particular cell, the FormatResultEx 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))"

When UnitsIn is visDate, you can pass a numeric value to the DATETIME function in StringOrNumber. The integer portion of the value you pass should represent the number of days since December 30, 1899, and the decimal portion should represent the fraction of a day since midnight. For example, 38135.50 represents noon on May 28th, 2004.

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 unit constants declared by the Visio type library in VisUnitCodes. A list of valid units is also included in About Units of Measure.

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 the units in which the returned string should be expressed. If you want the results expressed in the same units as the evaluated expression, pass "NOCAST" or visNoCast.

Format is a string that specifies a template or picture of the string produced by the FormatResultEx method. For details, see the FORMAT function. A few of the possibilities are:

# : Output a single digit, but not if it is a leading or trailing 0.

0 : Output a single digit, even if it is a leading or trailing 0.

. : Decimal placeholder.

, : Thousands separator.

"text" or 'text' : Output enclosed text as is.

\c : Output the character c.

When UnitsIn is visDate, Format should be one of the custom Microsoft Office Visio expanded-form date/time formats, which are of the form "{{ date/time format picture }}". You can view these formats in the Custom Format box in the Field dialog box in Visio. (Select a shape, and then, on the Insert menu, click Field. In the Category list, click Date/Time.)

The LangID argument is optional. If you don't specify a value, Visio uses the current system language. If you pass a value, the LangID argument should be one of the standard IDs used by Microsoft Windows to encode different language versions. For example, 1033 is the language ID for English (United States). To see a list of possible language IDs, search for "VERSIONINFO" in the Microsoft Platform SDK on MSDN.

The CalendarID argument should be one of the following values, which are declared in VisCellVals in the Visio type library. The default value is the Western calendar, visCalWestern.

Constant Value Description

visCalWestern

0

Western

visCalArabicHijri

1

Arabic Hijiri

visCalHebrewLunar

2

Hebrew Lunar

visCalChineseTaiwan

3

Taiwan Calendar

visCalJapaneseEmperor

4

Japanese Emperor Reign

visCalThaiBuddhism

5

Thai Buddhist

visCalKoreanDanki

6

Korean Danki

visCalSakaEra

7

Saka Era

visCalTranslitEnglish

8

English transliterated

visCalTranslitFrench

9

French transliterated

Example

The following example shows how to use the FormatResultEx property to format a date in Greek and display it as shape text.

Visual Basic for Applications
  Public Sub FormatResultEx_Example
Dim vsoShape As Visio.Shape
Dim strDate As String

Set vsoShape = ActivePage.DrawOval (3, 5, 5, 9)
strDate = Application.FormatResultEx (37663.50, visDate, "", "{{dd MMMM yyyy}}", 1032, 0)

vsoShape.Text = strDate

End Sub

See Also