Table of contents
TOC
Collapse the table of content
Expand the table of content

Application.FormatResultEx Method (Visio)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

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.

Syntax

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

expression A variable that represents an Application object.

Parameters

NameRequired/OptionalData TypeDescription
StringOrNumberRequiredVariantString or number to be formatted; can be passed as a string, floating point number, or integer.
UnitsInRequiredVariantMeasurement units to attribute to StringOrNumber.
UnitsOutRequiredVariantMeasurement units to express the result in.
FormatRequiredStringPicture of what the result string should look like.
LangIDOptionalLongThe language to use for the result string.
CalendarIDOptionalLonghe 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 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 inAbout 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 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 Data Format dialog box in Visio. (Select a shape, and then, on the Insert tab, click Field. In the Category list, click Date/Time, and then click Data Format.)

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 **
visCalWestern0Western
visCalArabicHijri1Arabic Hijiri
visCalHebrewLunar2Hebrew Lunar
visCalChineseTaiwan3Taiwan Calendar
visCalJapaneseEmperor4Japanese Emperor Reign
visCalThaiBuddhism5Thai Buddhist
visCalKoreanDanki6Korean Danki
visCalSakaEra7Saka Era
visCalTranslitEnglish8English transliterated
visCalTranslitFrench9French transliterated

Example

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

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
© 2018 Microsoft