Description
Performs a C-style sprintf to format a list of arguments into a string.
-
Return Type
-
A String value.
The converted string is returned.
-
Syntax
-
object.McSprintf (FormatString, [VariableNumberOfArguments()])
The McSprintf Method syntax has these parts: |
| object | An expression evaluating to an object of type McOMGlobal. | | FormatString | Required. A String value. The formatting string can contain text and formatting escape sequences of the form s for strings, d or x (hexadecmal conversion) for all integral types (byte, short integer or long integer). Use f or g for floating point types (either single precision float or double precision float). There is no formatting for currency or date types: you must convert these to a string and then use %s to place the string where you want it.
| | VariableNumberOfArguments() | Optional. An array of Variant values. An array of zero or more VARIANT arguments, each of which may be a scalar or array of any data type. The values may also be one of the built in user-defined-types (UDT): LONGPOINT, SINGLEPOINT or DOUBLEPOINT (and XXXXRECT or XXXXRANGE). You must explicitly break out the fields of your own defined UDT types. If an argument is an array or a UDT, the formatting string must contain a formatting escape sequence for each element of the array or each field of the UDT (see examples).
| Remarks
McSprintf allows you to convert an arbitrary number of arguments of virtually any string or numeric type into text under the control of a C-style sprinf formatting string.
When converting arrays to text, consider using McToText instead of McSprintf. McToText can deal with arrays of arbitrary length and allows you to specify a formatting string for text before, between and after the array, each value and each row of a mult-dimensionall array.
The McSprintf method does not recognize C-style, '\', escape sequences in either its FormatString or any strings included as arguments. However, as shown in the examples, you can use the McCStr method to convert C-style escape sequences.
The number of arguments is limited to about 100 and the output string is limited to about 8000 characters. Excessive arguments are ignored and output is truncated at the character limit, both without error.
Exceptions
If an argument is an array of variants, then each variant must be of the same data type. That is, Array(1,2,3) is legal, but Array(1,"2",3.0) is not.
|