Skip to main content

ModelCenter APIs 2026 R1 SP03

Interface ModelCenter::IPHXFormat

Last update: 30.07.2026

Definition: ModelCenter/src/ModelCenter.odl (line 6131)

Allows you to do custom formatting the same way ModelCenter does.

Example:

Dim formatter
Set formatter=app.getFormatter("# ?/2")
MsgBox formatter.doubleToString(12.5)

Members

Public functions

Function setFormat

void ModelCenter::IPHXFormat::setFormat(BSTR format)

Sets the format string to use in this object. Formats accepted are a sub-set of available formats from Excel. The easiest way to generate these is to load up ModelCenter and select "Format Variable" on some variable. The dialog will allow you to graphically choose a format and then will show you the correct format string to use in the lower left corner. You may pass in the empty string to mean "General".

Parameters:

  • format: The format string to use.

Parameters:

  • BSTR format

Return type: void

Function stringToLong

long ModelCenter::IPHXFormat::stringToLong(BSTR str)

Takes a formatted string and converts it to a long (integer). The string must be in the correct format for style being used.

Parameters:

  • str: The formatted string.

Returns:

The value of the string.

Parameters:

  • BSTR str

Return type: long

Function stringToDouble

double ModelCenter::IPHXFormat::stringToDouble(BSTR str)

Takes a formatted string and converts it to a double (real number). The string must be in the correct format for the style being used. For example, if percentage is being used, "1%" will convert to 0.01.

Parameters:

  • str: The formatted string.

Returns:

The value of the string.

Parameters:

  • BSTR str

Return type: double

Function longToString

BSTR ModelCenter::IPHXFormat::longToString(long val)

Takes a long (integer) and converts it to a formatted string.

Parameters:

  • val: The long number to format.

Returns:

The formatted string.

Parameters:

  • long val

Return type: BSTR

Function doubleToString

BSTR ModelCenter::IPHXFormat::doubleToString(double val)

Takes a double (real number) and converts it to a formatted string.

Parameters:

  • val: The double number to format.

Returns:

The formatted string.

Parameters:

  • double val

Return type: BSTR

Function getFormat

BSTR ModelCenter::IPHXFormat::getFormat()

Returns the current format style being used in this object.

Returns:


Return type: BSTR

Function stringToString

BSTR ModelCenter::IPHXFormat::stringToString(BSTR str)

Converts an unformatted string into a formatted string.

Parameters:

  • str: The unformatted string.

Returns:

The formatted string.

Parameters:

  • BSTR str

Return type: BSTR

Function longToEditableString

BSTR ModelCenter::IPHXFormat::longToEditableString(long val)

Converts a long to its formatted string representation but with full precision for editing.

Parameters:

  • val: The long number to format.

Returns:

The formatted string.

Parameters:

  • long val

Return type: BSTR

Function doubleToEditableString

BSTR ModelCenter::IPHXFormat::doubleToEditableString(double val)

Converts a double to its formatted string representation but with full precision for editing.

Parameters:

  • val: The double number to format.

Returns:

The formatted string.

Parameters:

  • double val

Return type: BSTR

Connect with Ansys