function
Format function
grammar
Format (expression [,format [,firstdayofweek[, firstweekofyear]])
Function function
In fact, the Format method has two forms, and the other is three parameters. The main difference is that it is thread-safe, but it is not used much. Only the first one is introduced here. The Format parameter is a format string used to format the value in Args. Args is an array of variables, that is, it can have multiple parameters, and each parameter can be different. For example:
Format ("My name is %6s", "Wind");
What I returned is: My name is Feng.
Required parameters for the expression. Any valid expression.
Format optional parameters. A valid named expression or user-defined format expression.
Firstdayofweek optional parameter. A constant representing the first day of the week.
Firstweekofyear optional parameter. A constant representing the first week of the year.
The format parameter has the following settings:
(0)
Numeric placeholder. Displays a number or zero. If the expression has a number at position 0 in the format string, the number is displayed; Otherwise, it shows zero. If the number of digits of a numerical value is less than the number of digits of zeros in the format expression (whether to the left or right of the decimal point), zeros are padded before or after it. If the number of digits to the right of the decimal point is greater than the number of digits to the right of the decimal point in the format expression, it is rounded to the last digit with zero. If the number of digits to the left of the decimal point is greater than that in the format expression, the extra part will be displayed without modification.
(#)
Numeric placeholder. Show one digit or not. If the expression has a number in the "#" position in the format string, it will be displayed; Otherwise, nothing will be displayed in this location.
The working principle of this symbol is basically the same as that of the "0" digit placeholder, except that when the number of digits in the expression is less than "#" (whether to the left or right of the decimal point), leading zeros or trailing zeros will not be displayed.
(.)
Decimal placeholder. In some countries, commas are used as decimal points. Decimal placeholders determine how many digits can be displayed around the decimal point. If the format expression only has the symbol to the left of the symbol, then the number less than 1 will start with the decimal point. If you want a "0" before the decimal point, please add a number placeholder "0" before the decimal point placeholder. When outputting format, the actual characters of decimal placeholders depend on the number format of the system.
(%)
Percent symbol placeholder. The expression is multiplied by 100. The percent sign (%) is inserted where it appears in the format string.
(,)
Placeholder for the thousandth symbol. In some countries, periods are used as thousands of symbols. The thousand-digit symbol mainly divides the digits above the left of the decimal point into thousands. If the format contains thousands of symbols around numeric placeholders (0 or #), specify the standard usage of thousands of symbols. Two adjacent thousandth symbols or one thousandth symbol are immediately to the left of the decimal point (whether decimal places are specified or not), which means "divide the value by 1000, and round it off as needed". For example, you can use the format string "##0," to represent 1 billion as 100. If the value is less than 1 million, it means "0". When two adjacent thousandth symbols appear anywhere other than the left of the decimal point, they are only regarded as designating the use of the thousandth symbol. The real characters of decimal placeholders need to depend on the number format recognized by the system when the format is output.
(:)
Time separator. In some countries, other symbols can be used as time separators. When formatting time values, you can use time separators to separate hours, minutes and seconds. The actual characters of the time separator depend on the system settings when the output format is used.
(/)
Date separator. In some countries, other symbols can be used as date separators. When formatting date values, you can use date separators to separate the year, month and day. The actual characters of the date separator depend on the system settings when the output format is used.
(E- E+ e- e+)
Scientific format. If the format expression contains at least one number placeholder (0 or #) to the right of e-, e+, E- or E+, the numerical value will be expressed in scientific format, and e or e will be placed between the number and the exponent. The number of digital placeholders to the right of e or e depends on the number of exponential digits. When e- or E- is used, the negative sign is used to indicate the negative power. When e+ or E+ is used, the negative sign indicates the negative power and the positive sign indicates the positive power.
- + $ ( )
Display text characters. If you want to display unlisted characters, you can prefix them with backslashes (\) or enclose them in double quotation marks ("").
(\)
Displays the next character in the formatted string. If you want to display a character with special meaning as the original character, you can put this character after the backslash (\). The backslash itself will not be displayed. The backslash (\) has the same effect as double quotation marks. If you want to display backslash characters, you can use two backslashes (\ \).
Those characters that cannot be displayed as literal characters are date format characters and time format characters (a, c, d, h, m, n, p, q, s, t, w, y,/and:), number format characters (#, 0,%, e, comma and period) and string format characters (@,&&). )。
(“ABC”)
Displays the string in double quotation marks (""). If you want to include a formatted string in the code, you must enclose the text with Chr(34) (34 is a character code with double quotation marks (")).
Reference:/link? URL = XM _ g _ x 5 dzqssixjpclpmryypsypr _ b 1 rjwtxmhitn-gv4 HLR _ h 1 vjilp 8 tvwyvvx a5 rhh 4 cmnfnbcn 5 vjksmcjhjmxwzhql 4 l 6 e 0 wytc 5 _