ID : 756
Format
Function
Return string type data for the designated expression format.
Syntax
Format(expression[, format])
Guaranteed entry
- expression
- This must be designated. Designate any expression. Data designated in argument expression will be converted according to the format of argument format.
- format
- This can be abbreviated.Expression formatted string in string type data should be used for designation.
Return value
Return string type data for the designated expression format.
Description
Return string type data for the designated expression format.
About Expression Formatted String
Strings used for designating expression format in argument format.
Interpret argument expression based on expression formatted string. Return the same string as Str function when cannot be interpreted.
Target format | Format configuration |
---|---|
Numeric value | Designate a numeric expression formatted string. |
String | Designate a character expression formatted string. |
Date and time | Designate a date/time expression formatted string. |
Related Terms
Language Setting, Numeric Expression Formatted String, Character Expression Formatted String, Date/Time Expression Formatted String, Str
Attention
- Return value varies depending on language setting.
- Signs used for the decimal point and thousand separator depend on the language used.
To make signs independent from the language, use Sprintf.
Sprintf determines “.” (a period) as a decimal point, and “,” (a comma) as a thousand separator for all languages.
Example
'!TITLE "Modification of Expression Format"
' Sample script of Format function
Sub Sample_Format
Dim aaa As Single
Dim bbb As String
aaa = 1234
PrintDbg Format(aaa, "000000") ' print "001234"
PrintDbg Format(aaa, "###,###.000") ' print "1,234.000"
PrintDbg Format(aaa, """Count:"""00000") ' print "Count:01234"
bbb = "aBc"
PrintDbg Format(bbb, "@@@@@") ' print " aBc" (right-aligned 5 characters)
PrintDbg Format(bbb, "!@@@@@") ' print "aBc " (left-aligned 5 characters)
PrintDbg Format(bbb, ">") ' print "ABC"
End Sub
ID : 756