Format

xiaoxiao2021-03-06  99

This article is taken from the "Daeng Forum" Blyb formatted string using plus sign ( ) operator and conversion function (such as INTOSTR), you really can combine existing values ​​into a string, but another way can format numbers, Currency values ​​and other strings, this is the powerful Format function and its family. The Format function parameters include: a basic text string, some placeholders (usually marked by% symbol) and a numeric array, each value in the array corresponds to one placeholder. For example, the code formatted into a string is as follows: Format ('first% d, second% d', [N1, N2]); where N1 and N2 are two integer values, the first placeholder Instead of the first value, the second placeholder is replaced by the second value, and so on. If the placeholder output type (the letter represented by the% symbol) does not match the corresponding parameter type, a runtime error will be generated, so setting the compile time type check will help the use of the Format function. In addition to% D, the FORMAT function also defines many placeholders. These placeholders define the default output of the corresponding data type, you can change the default output with a deeper format constraint, such as a width constraint determines the number of characters in the output, and accuracy constraint determines the number of bits of the decimal point. For example, Format ('% 8D', [N1]); this sentence converts the number N1 into a string of 8 characters, and the text is aligned by filling blank, and the left is left alternately (-). Placeholder Description D (DECIMAL) Converts the integer value to the decimal digital string x (Hexadecimal) converts the integer value to hexadecimal numeric string P (Pointer) converts the pointer value to a hexadecimal numeric character String S (String) copy string, character, or character pointer value to an output string E (Exponential) converts floating point values ​​to index represented string f (floatingpoint) converts floating point values ​​to floating point representations String G (General) Use floating point or index to convert floating-point values ​​to the shortest decimal string n (Number) converts floating-point values ​​to floating point values ​​M (Money) with thousands of separators to convert floating point values ​​to The string of cash is represented, and the conversion result depends on the regional settings. For details, please

This example displays a message on the form's status bar indicating the record count after a record is deleted.procedure TForm1.MyDataAfterDelete (DataSet: TDataSet); begin StatusBar1.SimpleText: = Format ( 'There are now% d records in the table', [Dataset.recordcount]);

转载请注明原文地址:https://www.9cbs.com/read-95608.html

New Post(0)