Format
 
Formats a number in a specified format

Syntax

Declare Function Format ( ByVal numerical_expression As Double, ByRef formatting_expression As Const String = "
" ) As String

Usage

#include "string.bi"
result = Format[$]( numerical_expression, formatting_expression )

Parameters

numerical_expression
number to format
formatting_expression
formatting pattern pattern

Return Value

Format returns a string with the result of the numerical expression formatted as indicated in the formatting expression.
The formatting expression is a string that can yield numeric or date-time values.

Description

To recover meaningful date-time values the numerical expression must be a date serial obtained from the appropriate functions.
This function is part of FreeBASIC, however it is not recognized by the compiler unless vbcompat.bi is included.

"Numeric Formats"
Symbol Description
Null string General format (no formatting)
0 Digit placeholder: If the number has fewer digits than there are zeros (on either side of the decimal) in the format expression, leading or trailing zeros are displayed. If there are more digits to the right of the decimal than zeros in the format, the number is rounded. If there are more digits to the left of the decimal than zeros in the format the digits are all displayed
# Digit placeholder: Follows the same rules as for the 0 digit except the leading or trailing zeros are not displayed
. Placeholder for decimal point.If the format contains only #'s to the left of . then numbers smaller than 1 are begun with a decimal point.
% Percentage :The expression is multiplied by 100 and the % character is inserted.
, Thousands separator. Two adjacent commas, or a comma immediately to the left of the decimal point location (whether there is a decimal specified or not) means 'Omit the three digits that fall between these commas, or between the comma and the decimal point, rounding as needed.'
E- E+ e- e+ Scientific format: If a format contains one digit placeholder (0 or #) to the right of an E-, E+, e-, or e+, the number is displayed in scientific format and an E or e is inserted between the number and its exponent.The number of 0's or #'s to the right determines the number of digits in the exponent. Use E- or e- to place a minus sign next to negative exponents. Use a E+ or e+ to place a minus sign next to negative exponents and a plus sign next to positive exponents.
: ? + $ () space Display literal character To display a character other than one of these, precede the character with a backslash (\) or enclose the character(s) in double quotation marks
\ Display next character in format string as it is
text between double quotes Displays the text inside the double quotes.
: Time separator is used to separate hours, minutes, and seconds when time values are formatted.
/ The date separator is used to separate day,month, and year when date values are formatted.


"Date-Time formats:"
Symbol Description
d, dd Display the day as a one-digit/two-digit number (1-31/01-31)
ddd Display the day as an abbreviation (Sun-Sat)
dddd Display the day as a full name (Sunday-Saturday)
ddddd Display a serial date number as a complete date (including day, month and year)
m, mm Display the month as a one-digit/two-digit number (1-12/01-12). If immediately following h or hh, the minute rather than the month is displayed
M, MM Display the month as a one-digit/two-digit number (1-12/01-12), even if immediately following h or hh
mmm Display the month as an abbreviation (Jan-Dec)
mmmm Display the month as a full name (January-December)
y, yy Display the year as a two-digit number (00-99)
yyyy Display the year as a four-digit number (1900-2040)
h, hh Display the hour as a one-digit/two-digit number (0-23/00-23)
m, mm Display the minute as a one-digit/two-digit number (0-59/00-59). If not immediately following h or hh, the month rather than the minute is displayed
n, nn Display the minute as a one-digit/two-digit number (0-59/00-59), even if not immediately following h or hh
s, ss Display the second as a one-digit/two-digit number (0-59/00-59)
ttttt Display a time serial number as a complete time, including hour, minute and second
AM/PM (Default), am/pm Use the 12-hour clock displaying AM or am with any hour before noon, PM or pm with any hour between noon and 11:59
A/P, a/p Use the 12-hour clock displaying A or a with any hour before noon, P or p with any hour between noon and 11:59



Example

Sample numeric formats
Format (fmt)                  5             -5            .5
	    
	    Null String                   5             -5            0.5
	    0                             5             -5            1
	    0.00                          5.00          -5.00         0.50
	    #,##0                         5             -5            1
	    #,##0.00                      5.00          -5.00         0.50
	    $#,##0;($#,##0)               $5            ($5)          $1
	    $#,##0.00;($#,##0.00)         $5.00         ($5.00)       $0.50
	    0%                            500%          -500%         50%
	    0.00%                         500.00%       -500.00%      50.00%
	    0.00E+00                      5.00E+00      -5.00E+00     5.00E-01
	    0.00E-00                      5.00E00       -5.00E00      5.00E-01
 Sample Date And Time Formats
The following are examples of Date And Time formats:
	     Format  Expression     Display
	     m/d/yy                 12/7/58
	     d-mmmm-yy              7-December-58
	     d-mmmm                 7-December
	     mmmm-yy                December-58
	     h:mm AM/PM             8:50 PM
	     h:mm:ss AM/PM          8:50:35 PM
	     h:mm                   20:50
	     h:mm:ss                20:50:35
	     m/d/yy h:mm            12/7/58 20:50 

Dialect Differences

None

Differences from QB

  • Does not exist in QB 4.5. This function appeared first in PDS 7.1

See also

Сайт ПДСНПСР. Если ты патриот России - жми сюда!


Знаете ли Вы, что, как и всякая идолопоклонническая религия, релятивизм представляет собой инструмент идеологического подчинения одних людей другим с помощью абсолютно бессовестной манипуляции их психикой для достижения интересов определенных групп людей, стоящих у руля этой воровской машины? Подробнее читайте в FAQ по эфирной физике.

НОВОСТИ ФОРУМАФорум Рыцари теории эфира
Рыцари теории эфира
 10.11.2021 - 12:37: ПЕРСОНАЛИИ - Personalias -> WHO IS WHO - КТО ЕСТЬ КТО - Карим_Хайдаров.
10.11.2021 - 12:36: СОВЕСТЬ - Conscience -> РАСЧЕЛОВЕЧИВАНИЕ ЧЕЛОВЕКА. КОМУ ЭТО НАДО? - Карим_Хайдаров.
10.11.2021 - 12:36: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от д.м.н. Александра Алексеевича Редько - Карим_Хайдаров.
10.11.2021 - 12:35: ЭКОЛОГИЯ - Ecology -> Биологическая безопасность населения - Карим_Хайдаров.
10.11.2021 - 12:34: ВОЙНА, ПОЛИТИКА И НАУКА - War, Politics and Science -> Проблема государственного терроризма - Карим_Хайдаров.
10.11.2021 - 12:34: ВОЙНА, ПОЛИТИКА И НАУКА - War, Politics and Science -> ПРАВОСУДИЯ.НЕТ - Карим_Хайдаров.
10.11.2021 - 12:34: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от Вадима Глогера, США - Карим_Хайдаров.
10.11.2021 - 09:18: НОВЫЕ ТЕХНОЛОГИИ - New Technologies -> Волновая генетика Петра Гаряева, 5G-контроль и управление - Карим_Хайдаров.
10.11.2021 - 09:18: ЭКОЛОГИЯ - Ecology -> ЭКОЛОГИЯ ДЛЯ ВСЕХ - Карим_Хайдаров.
10.11.2021 - 09:16: ЭКОЛОГИЯ - Ecology -> ПРОБЛЕМЫ МЕДИЦИНЫ - Карим_Хайдаров.
10.11.2021 - 09:15: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от Екатерины Коваленко - Карим_Хайдаров.
10.11.2021 - 09:13: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от Вильгельма Варкентина - Карим_Хайдаров.
Bourabai Research Institution home page

Боровское исследовательское учреждение - Bourabai Research Bourabai Research Institution