Strings.Format(Object, String) Yöntem
Tanım
Biçim ifadesinde bulunan yönergelere göre biçimlendirilen bir dize döndürür String .Returns a string formatted according to instructions contained in a format String expression.
public static string Format (object? Expression, string? Style = "");
public static string Format (object Expression, string Style = "");
static member Format : obj * string -> string
Public Function Format (Expression As Object, Optional Style As String = "") As String
Parametreler
- Expression
- Object
Gereklidir.Required. Herhangi bir geçerli ifade.Any valid expression.
- Style
- String
İsteğe bağlı.Optional. Geçerli bir adlandırılmış veya Kullanıcı tanımlı biçim String ifadesi.A valid named or user-defined format String expression.
Döndürülenler
Biçim ifadesinde bulunan yönergelere göre biçimlendirilen bir dize String .A string formatted according to instructions contained in a format String expression.
Örnekler
Bu örnek, Format her iki String biçimi ve Kullanıcı tanımlı biçimleri kullanarak değerleri biçimlendirmek için işlevinin çeşitli kullanımlarını gösterir.This example shows various uses of the Format function to format values using both String formats and user-defined formats. Tarih ayırıcısı ( / ), zaman ayırıcısı ( : ) ve ı/PM göstergeleri ( t ve tt ) için, sisteminiz tarafından görünen gerçek biçimli çıktı, kodun kullandığı yerel ayar ayarlarına bağlıdır.For the date separator (/), time separator (:), and the AM/PM indicators (t and tt), the actual formatted output displayed by your system depends on the locale settings the code is using. Geliştirme ortamında saat ve tarihler görüntülendiğinde, kod yerel ayarının kısa saat biçimi ve kısa tarih biçimi kullanılır.When times and dates are displayed in the development environment, the short time format and short date format of the code locale are used.
Not
24 saatlik bir saat kullanan yerel ayarlarda, ı/PM göstergeleri ( t ve tt ) hiçbir şey görüntülemez.For locales that use a 24-hour clock, the AM/PM indicators (t and tt) display nothing.
Dim testDateTime As Date = #1/27/2001 5:04:23 PM#
Dim testStr As String
' Returns current system time in the system-defined long time format.
testStr = Format(Now(), "Long Time")
' Returns current system date in the system-defined long date format.
testStr = Format(Now(), "Long Date")
' Also returns current system date in the system-defined long date
' format, using the single letter code for the format.
testStr = Format(Now(), "D")
' Returns the value of testDateTime in user-defined date/time formats.
' Returns "5:4:23".
testStr = Format(testDateTime, "h:m:s")
' Returns "05:04:23 PM".
testStr = Format(testDateTime, "hh:mm:ss tt")
' Returns "Saturday, Jan 27 2001".
testStr = Format(testDateTime, "dddd, MMM d yyyy")
' Returns "17:04:23".
testStr = Format(testDateTime, "HH:mm:ss")
' Returns "23".
testStr = Format(23)
' User-defined numeric formats.
' Returns "5,459.40".
testStr = Format(5459.4, "##,##0.00")
' Returns "334.90".
testStr = Format(334.9, "###0.00")
' Returns "500.00%".
testStr = Format(5, "0.00%")
Açıklamalar
String.FormatYöntemi de benzer işlevsellik sağlar.The String.Format method also provides similar functionality.
Yerelleştirilmiş olmayan bir sayısal dizeyi biçimlendirirken, istediğiniz görünümü aldığınızdan emin olmak için Kullanıcı tanımlı sayısal bir biçim kullanmanız gerekir.If you are formatting a nonlocalized numeric string, you should use a user-defined numeric format to ensure that you get the look you want.
Bir sayıyı belirtmeden biçimlendirmeye çalışırsanız, Style Format işlev, uluslararası olarak Str farkında olsa da işleve benzer işlevler sağlar.If you try to format a number without specifying Style, the Format function provides functionality similar to the Str function, although it is internationally aware. Ancak, işlevi kullanılarak dizeler olarak biçimlendirilen pozitif sayılar Format değerin işareti için ayrılmış bir boşluk değeri içermez; işlev kullanılarak dönüştürülen Str boşluk, baştaki boşluğu korurlar.However, positive numbers formatted as strings using the Format function don't include a leading space reserved for the sign of the value; those converted using the Str function retain the leading space.
Farklı Sayısal Değerler İçin Farklı BiçimlerDifferent Formats for Different Numeric Values
Sayılara yönelik kullanıcı tanımlı bir biçim ifadesinin noktalı virgülle ayrılmış bir ila üç bölümü olabilir.A user-defined format expression for numbers can have from one to three sections separated by semicolons. Styleİşlevin bağımsız değişkeni Format önceden tanımlanmış sayısal biçimlerden birini içeriyorsa, yalnızca bir bölüme izin verilir.If the Style argument of the Format function contains one of the predefined numeric formats, only one section is allowed.
| Bunu kullanırsanızIf you use | Sonucu bu olurThis is the result |
|---|---|
| Yalnızca bir bölümOne section only | Biçim ifadesi tüm değerler için geçerlidir.The format expression applies to all values. |
| İki bölümTwo sections | İlk bölüm pozitif değerlere ve sıfırlara, ikinci bölüm ise negatif değerlere uygulanır.The first section applies to positive values and zeros; the second applies to negative values. |
| Üç bölümThree sections | İlk bölüm pozitif değerlere, ikinci bölüm negatif değerlere, üçüncü ise sıfırlara uygulanır.The first section applies to positive values, the second applies to negative values, and the third applies to zeros. |
Aşağıdaki örnek iki bölümden oluşur: ilki pozitif değerler ve sıfırlar için biçimi tanımlar; İkinci bölüm negatif değerler için biçimi tanımlar.The following example has two sections: the first defines the format for positive values and zeros; the second section defines the format for negative values. Styleİşlevin bağımsız değişkeni Format bir dize aldığında, tırnak işaretleri içine alınır.Since the Style argument of the Format function takes a string, it is enclosed by quotation marks.
Dim style1 As String = "$#,##0;($#,##0)"
Aralarında bir şey olmayan noktalı virgüller eklerseniz, eksik bölüm pozitif değerin biçimi kullanılarak yazdırılır.If you include semicolons with nothing between them, the missing section is printed using the format of the positive value. Örneğin, aşağıdaki biçim ilk bölümdeki biçimi kullanarak pozitif ve negatif değerleri görüntüler ve Zero değer sıfır ise görüntüler.For example, the following format displays positive and negative values using the format in the first section and displays Zero if the value is zero.
Dim style2 As String = "$#,##0;;\Z\e\r\o"
Önceden Tanımlanmış Sayısal BiçimlerPredefined Numeric Formats
Aşağıdaki tabloda önceden tanımlı sayısal biçim adları tanımlanmaktadır.The following table identifies the predefined numeric format names. Bunlar Style , işlevin bağımsız değişkeni olarak ad tarafından kullanılabilir Format :These may be used by name as the Style argument for the Format function:
| Biçim adıFormat name | DescriptionDescription |
|---|---|
General Number, G , veya gGeneral Number, G, or g |
Sayıyı bin ayırıcısı olmadan görüntüler.Displays number with no thousand separator. Örneğin, Format(&H3FA, "g") döndürür 1018 .For example, Format(&H3FA, "g") returns 1018. |
Currency, C , veya cCurrency, C, or c |
Uygunsa binlik ayırıcıyla sayıyı görüntüler; ondalık ayırıcının sağında iki basamak görüntüler.Displays number with thousand separator, if appropriate; displays two digits to the right of the decimal separator. Çıktı, sistemin yerel ayarlarını temel alır.Output is based on system locale settings. Örneğin, Format(1234567, "c") döndürür $1,234,567.00 .For example, Format(1234567, "c") returns $1,234,567.00. |
Fixed, F , veya fFixed, F, or f |
Sol tarafta en az bir basamak ve ondalık ayırıcısının sağında iki basamak gösterir.Displays at least one digit to the left and two digits to the right of the decimal separator. Örneğin, Format(1234567, "f") döndürür 1234567.00 .For example, Format(1234567, "f") returns 1234567.00. |
Standard, N , veya nStandard, N, or n |
Sayıyı binlik ayırıcıyla, en az bir basamakla sola ve ondalık ayırıcının sağında iki basamakla gösterir.Displays number with thousand separator, at least one digit to the left and two digits to the right of the decimal separator. Örneğin, Format(1234567, "n") döndürür 1,234,567.00 .For example, Format(1234567, "n") returns 1,234,567.00. |
Percent |
Sayıyı 100 ile çarpıp hemen sağına bir yüzde işareti (%) ekleyerek gösterir; ondalık ayırıcısının sağ tarafında her zaman iki basamak gösterir.Displays number multiplied by 100 with a percent sign (%) appended immediately to the right; always displays two digits to the right of the decimal separator. Örneğin, Format(0.4744, "Percent") döndürür 47.44% .For example, Format(0.4744, "Percent") returns 47.44%. |
P veya pP, or p |
Binde ayırıcısı ile, yüzde işareti (%) ile 100 ile çarpıldığı sayıyı görüntüler sağa eklenen ve tek bir boşlukla ayrılmış; her zaman ondalık ayırıcının sağında iki basamak görüntüler.Displays number with thousandths separator multiplied by 100 with a percent sign (%) appended to the right and separated by a single space; always displays two digits to the right of the decimal separator. Örneğin, Format(0.80345, "p") döndürür 80.35 % .For example, Format(0.80345, "p") returns 80.35 %. |
Scientific |
Standart bilimsel gösterimi kullanır ve iki önemli basamak belirtir.Uses standard scientific notation, providing two significant digits. Örneğin, Format(1234567, "Scientific") döndürür 1.23E+06 .For example, Format(1234567, "Scientific") returns 1.23E+06. |
E veya eE, or e |
Standart bilimsel gösterimi kullanır ve altı önemli basamak sağlar.Uses standard scientific notation, providing six significant digits. Örneğin, Format(1234567, "e") döndürür 1.234567e+006 .For example, Format(1234567, "e") returns 1.234567e+006. |
D veya dD, or d |
Sayıyı ondalık (10 tabanında) biçimindeki sayının değerini içeren bir dize olarak görüntüler.Displays number as a string that contains the value of the number in Decimal (base 10) format. Bu seçenek yalnızca integral türleri (,, Byte Short Integer ,) için desteklenir Long .This option is supported for integral types (Byte, Short, Integer, Long) only.Örneğin, Format(&H7F, "d") döndürür 127 .For example, Format(&H7F, "d") returns 127. |
X veya xX, or x |
Sayıyı onaltılık (taban 16) biçimindeki sayının değerini içeren bir dize olarak görüntüler.Displays number as a string that contains the value of the number in Hexadecimal (base 16) format. Bu seçenek yalnızca integral türleri (,, Byte Short Integer ,) için desteklenir Long .This option is supported for integral types (Byte, Short, Integer, Long) only.Örneğin, Format(127, "x") döndürür 7f .For example, Format(127, "x") returns 7f. |
Yes/No |
NoSayı 0 ise görüntüler; Aksi takdirde görüntüler Yes .Displays No if number is 0; otherwise, displays Yes.Örneğin, Format(0, "Yes/No") döndürür No .For example, Format(0, "Yes/No") returns No. |
True/False |
FalseSayı 0 ise görüntüler; Aksi takdirde görüntüler True .Displays False if number is 0; otherwise, displays True.Örneğin, Format(1, "True/False") döndürür True .For example, Format(1, "True/False") returns True. |
On/Off |
OffSayı 0 ise görüntüler; Aksi takdirde görüntüler On .Displays Off if number is 0; otherwise, displays On.Örneğin, Format(1, "On/Off") döndürür On .For example, Format(1, "On/Off") returns On. |
Akıllı Cihaz Geliştirici NotlarıSmart Device Developer Notes
Yes/No, True/False , Ve On/Off biçimleri desteklenmez.The Yes/No, True/False, and On/Off formats are not supported.
Kullanıcı Tanımlı Sayısal BiçimlerUser-Defined Numeric Formats
Aşağıdaki tabloda kullanıcı tanımlı sayı biçimleri oluşturmak için kullanabileceğiniz karakterler tanımlanmaktadır.The following table identifies characters you can use to create user-defined number formats. Bunlar Style , işlevin bağımsız değişkenini oluşturmak için kullanılabilir Format :These may be used to build the Style argument for the Format function:
| KarakterCharacter | AçıklamaDescription |
|---|---|
| HiçbiriNone | Sayıyı biçimlendirme olmadan görüntüler.Displays the number with no formatting. |
(0)(0) |
Basamak yer tutucusu.Digit placeholder. Bir basamak veya sıfır görüntüler.Displays a digit or a zero. İfadenin biçim dizesinde sıfır göründüğü konumda bir basamak varsa, bunu görüntüleyin; Aksi takdirde, bu konumda bir sıfır görüntüler.If the expression has a digit in the position where the zero appears in the format string, display it; otherwise, displays a zero in that position. Sayı, biçim ifadesinde sıfırlardan daha az basamak içeriyorsa (ondalık ayırıcısının her iki tarafında), baştaki veya sondaki sıfırları görüntüler.If the number has fewer digits than there are zeros (on either side of the decimal) in the format expression, displays leading or trailing zeros. Sayının ondalık ayırıcısının sağındaki basamak sayısı biçim ifadesindeki ondalık ayırıcısının sağında bulunan sıfırlardan daha fazlaysa, sayıyı sıfır sayısı kadar ondalık basamak olacak şekilde yuvarlar.If the number has more digits to the right of the decimal separator than there are zeros to the right of the decimal separator in the format expression, rounds the number to as many decimal places as there are zeros. Sayının ondalık ayırıcısının solundaki basamak sayısı biçim ifadesindeki ondalık ayırıcısının solunda bulunan sıfırlardan daha fazlaysa, fazla basamakları değiştirmeden görüntüler.If the number has more digits to the left of the decimal separator than there are zeros to the left of the decimal separator in the format expression, displays the extra digits without modification. |
(#)(#) |
Basamak yer tutucusu.Digit placeholder. Bir basamak görüntüler veya hiçbir şey görüntülemez.Displays a digit or nothing. İfadenin # Biçim dizesinde karakterin göründüğü konumda bir basamak varsa, bunu görüntüler; Aksi takdirde, bu konumda hiçbir şey görüntülemez.If the expression has a digit in the position where the # character appears in the format string, displays it; otherwise, displays nothing in that position.Bu simge 0 basamak yer tutucusu gibi çalışarak, sayının, # Biçim ifadesindeki ondalık ayırıcının her iki yanındaki karakterlerden daha az basamak içermesi durumunda, baştaki ve sondaki sıfırların görüntülenmediğinden emin olmak gibi.This symbol works like the 0 digit placeholder, except that leading and trailing zeros aren't displayed if the number has fewer digits than there are # characters on either side of the decimal separator in the format expression. |
(.)(.) |
Ondalık yer tutucusu.Decimal placeholder. Ondalık yer tutucusu, ondalık basamağının solunda ve sağında kaç tane basamağın gösterildiğini belirler.The decimal placeholder determines how many digits are displayed to the left and right of the decimal separator. Biçim ifadesi # Bu sembolün solunda yalnızca karakterler içeriyorsa, 1 ' den küçük sayılar ondalık ayırıcısıyla başlar.If the format expression contains only # characters to the left of this symbol; numbers smaller than 1 begin with a decimal separator. Kesirli sayıların başında bir sıfır göstermek için, ondalık ayırıcısının solundaki birinci basamak yer tutucusu olarak sıfır kullanın.To display a leading zero displayed with fractional numbers, use zero as the first digit placeholder to the left of the decimal separator. Bazı yerel ayarlarda, ondalık ayırıcısı olarak virgül kullanılır.In some locales, a comma is used as the decimal separator. Biçimlendirilen çıktıda ondalık yer tutucusu olarak kullanılan gerçek karakter, sisteminiz tarafından tanınan sayı biçimine bağlıdır.The actual character used as a decimal placeholder in the formatted output depends on the number format recognized by your system. Bu nedenle ondalık yer tutucu olarak virgül kullanan bir yerel ayarda olsanız dahi biçimlerinizde ondalık yer tutucu olarak nokta kullanmanız gerekir.Thus, you should use the period as the decimal placeholder in your formats even if you are in a locale that uses a comma as a decimal placeholder. Biçimlendirilen dize, yerel ayar için doğru biçimde görünür.The formatted string will appear in the format correct for the locale. |
(%)(%) |
Yüzde yer tutucusu.Percent placeholder. İfadeyi 100 ile çarpar.Multiplies the expression by 100. Biçim dizesinde göründüğü konuma yüzde karakteri ( % ) eklenir.The percent character (%) is inserted in the position where it appears in the format string. |
(,)(,) |
Binlik ayıracı.Thousand separator. Binlik ayıracı, ondalık ayırıcısının solunda dört veya daha fazla basamağı olan bir sayının içinde binleri yüzlerden ayırır.The thousand separator separates thousands from hundreds within a number that has four or more places to the left of the decimal separator. Biçim, basamak yer tutucuları (veya) ile çevrelenen bir bin ayırıcısı içeriyorsa, bin ayracın standart kullanımı belirtilir 0 # .Standard use of the thousand separator is specified if the format contains a thousand separator surrounded by digit placeholders (0 or #).Ondalık ayırıcısının hemen solunda bulunan veya dizenin en sağındaki karakter olan bir binlik ayıracı (ondalık belirtilmiş olsun veya olmasın), "sayıyı 1.000’e bölüp gerektiğinde yuvarlayarak ölçeklendirme" anlamına gelir.A thousand separator immediately to the left of the decimal separator (whether or not a decimal is specified) or as the rightmost character in the string means "scale the number by dividing it by 1,000, rounding as needed." 1.000 ' den küçük, ancak 500 ' den küçük veya eşit sayılar olarak görüntülenir 1 ve 500 ' den küçük olan sayılar olarak görüntülenir 0 .Numbers smaller than 1,000 but greater or equal to 500 are displayed as 1, and numbers smaller than 500 are displayed as 0. Bu konumdaki iki bitişik binlik ayıracı, 1 milyon ölçeğine göre ve her ek ayırıcı için 1.000 ek ölçeğine göre ölçeklendirme yapar.Two adjacent thousand separators in this position scale by a factor of 1 million, and an additional factor of 1,000 for each additional separator.Ondalık ayırıcısının hemen solu dışında herhangi bir konumdaki veya dizenin en sağındaki birden fazla ayırıcının, binlik ayıracı kullanımını belirttiği kabul edilir.Multiple separators in any position other than immediately to the left of the decimal separator or the rightmost position in the string are treated simply as specifying the use of a thousand separator. Bazı yerel ayarlarda, binlik ayıracı olarak nokta kullanılır.In some locales, a period is used as a thousand separator. Biçimlendirilen çıktıda binlik ayıracı olarak kullanılan gerçek karakter, sisteminiz tarafından tanınan Sayı Biçimine bağlıdır.The actual character used as the thousand separator in the formatted output depends on the Number Format recognized by your system. Bu nedenle binlik ayıracı olarak nokta kullanan bir yerel ayarda olsanız dahi biçimlerinizde binlik ayıracı olarak virgül kullanmanız gerekir.Thus, you should use the comma as the thousand separator in your formats even if you are in a locale that uses a period as a thousand separator. Biçimlendirilen dize, yerel ayar için doğru biçimde görünür.The formatted string will appear in the format correct for the locale. Örnek olarak aşağıdaki üç biçim dizesini inceleyin:For example, consider the three following format strings: - "#,0."Bu, 100.000.000 sayısını "100.000.000" dizesi olarak biçimlendirmek için binlik ayırıcısını kullanır.- "#,0.", which uses the thousands separator to format the number 100 million as the string "100,000,000".- "#0,.", 100.000.000 sayısını "100000" dizesi olarak biçimlendirmek için 1000 faktörüyle ölçeklendirmeyi kullanan.- "#0,.", which uses scaling by a factor of one thousand to format the number 100 million as the string "100000".- "#,0,.", "100.000" dizesi olarak 100.000.000 sayısını biçimlendirmek için binlerce ayırıcıyı ve 1000 ile ölçeklendirmeyi kullanır.- "#,0,.", which uses the thousands separator and scaling by one thousand to format the number 100 million as the string "100,000". |
(:)(:) |
Tarih ayırıcısı.Time separator. Bazı yerel ayarlarda, saat ayırıcısını temsil etmek için başka karakterler kullanılabilir.In some locales, other characters may be used to represent the time separator. Saat ayırıcısı, saat değerleri biçimlendirilirken saat, dakika ve saniyeleri ayırır.The time separator separates hours, minutes, and seconds when time values are formatted. Biçimlendirilmiş çıktıda saat ayırıcısı olarak kullanılan gerçek karakter, sistem ayarlarınıza göre belirlenir.The actual character used as the time separator in formatted output is determined by your system settings. |
(/)(/) |
Tarih ayırıcısı.Date separator. Bazı yerel ayarlarda, tarih ayırıcısını temsil etmek için başka karakterler kullanılabilir.In some locales, other characters may be used to represent the date separator. Tarih ayırıcısı, tarih değerleri biçimlendirilirken gün, ay ve yılı ayırır.The date separator separates the day, month, and year when date values are formatted. Biçimlendirilmiş çıktıda tarih ayırıcısı olarak kullanılan gerçek karakter, sistem ayarlarınıza göre belirlenir.The actual character used as the date separator in formatted output is determined by your system settings. |
(E-``E+``e-``e+)(E-``E+``e-``e+) |
Bilimsel biçim.Scientific format. Biçim ifadesi,,, veya solunda en az bir rakam yer tutucusu ( 0 veya) içeriyorsa, # E- E+ e- e+ sayı bilimsel biçimde görüntülenir ve E e sayı ile üs değeri arasına eklenir.If the format expression contains at least one digit placeholder (0 or #) to the left of E-, E+, e-, or e+, the number is displayed in scientific format and E or e is inserted between the number and its exponent. Soldaki basamak yer tutucularının sayısı, üs içindeki basamak sayısını belirler.The number of digit placeholders to the left determines the number of digits in the exponent. E- e- Negatif üslerin yanına eksi işareti koymak için veya kullanın.Use E- or e- to place a minus sign next to negative exponents. E+ e+ Negatif üslerin yanına eksi işareti ve pozitif üslerin yanında artı işareti koymak için veya kullanın.Use E+ or e+ to place a minus sign next to negative exponents and a plus sign next to positive exponents. Doğru biçimlendirmeye ulaşmak için bu sembolün sağına basamak yer tutucuları de dahil etmeniz gerekir.You must also include digit placeholders to the right of this symbol to get correct formatting. |
- + $ ( )- + $ ( ) |
Değişmez karakterler.Literal characters. Bu karakterler biçimlendirme dizesinde yazıldığı şekilde görüntülenir.These characters are displayed exactly as typed in the format string. Listelenenlerin dışında bir karakter görüntülemek için, önüne bir ters eğik çizgi koyun (\) veya çift tırnak işareti (" ") içine alın.To display a character other than one of those listed, precede it with a backslash (\) or enclose it in double quotation marks (" "). |
(\)(\) |
Biçim dizesinde bir sonraki karakteri görüntüler.Displays the next character in the format string. Özel anlamı olan bir karakteri değişmez karakter olarak görüntülemek için önüne bir ters eğik çizgi (\) koyun.To display a character that has special meaning as a literal character, precede it with a backslash (\). Ters eğik çizgi gösterilmez.The backslash itself isn't displayed. Ters eğik çizgi kullanmak, sonraki karakteri çift tırnak işaretleri içine almakla aynıdır.Using a backslash is the same as enclosing the next character in double quotation marks. Bir ters eğik çizgiyi göstermek için iki ters eğik çizgi (\\) kullanın.To display a backslash, use two backslashes (\\).Sabit karakter olarak görüntülenmeyen karakter örnekleri; Tarih biçimlendirme ve zaman biçimlendirme karakterleri (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, a c d h m n p q s t w y / : # 0 % E e ve) ve dize biçimlendirme karakterleri ( @ , & , < ,, > ve ! ).Examples of characters that can't be displayed as literal characters are the date-formatting and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, /, and :), the numeric-formatting characters (#, 0, %, E, e, comma, and period), and the string-formatting characters (@, &, <, >, and !). |
("``ABC``")("``ABC``") |
Dizeyi çift tırnak işaretleri (" ") içinde görüntüler.Displays the string inside the double quotation marks (" "). Kodun içinden stil bağımsız değişkenine bir dize eklemek için, Chr(34) metni ( 34 tırnak işareti (") için karakter kodu) içine almanız için kullanmanız gerekir.To include a string in the style argument from within code, you must use Chr(34) to enclose the text (34 is the character code for a quotation mark (")). |
Eski kod örneğiLegacy Code Example
Aşağıdaki tabloda sayılar için bazı örnek biçim ifadeleri yer almaktadır.The following table contains some sample format expressions for numbers. (Bu örnekler, sisteminizin yerel ayar ayarının Ingilizce-U. S olduğunu varsayar.) İlk sütun, işlevin bağımsız değişkeninin biçim dizelerini içerir Style Format ; biçimlendirilen veriler sütun başlıklarında verilen değere sahipse, diğer sütunlar ortaya çıkan çıktıyı içerir.(These examples all assume that your system's locale setting is English-U.S.) The first column contains the format strings for the Style argument of the Format function; the other columns contain the resulting output if the formatted data has the value given in the column headings.
Format ( Style )Format (Style) |
"5" için biçimlendirme şekli"5" formatted as | "-5" için biçimlendirme şekli"-5" formatted as | "0,5" için biçimlendirme şekli"0.5" formatted as |
|---|---|---|---|
Zero-length string ("") |
5 |
-5 |
0.5 |
0 |
5 |
-5 |
1 |
0.00 |
5.00 |
-5.00 |
0.50 |
#,##0 |
5 |
-5 |
1 |
$#,##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 |
Önceden Tanımlanmış Tarih/Saat BiçimleriPredefined Date/Time Formats
Aşağıdaki tabloda önceden tanımlı tarih ve saat biçimi adları tanımlanmaktadır.The following table identifies the predefined date and time format names. Bunlar, işlevin stil bağımsız değişkeni olarak ad tarafından kullanılabilir Format :These may be used by name as the style argument for the Format function:
| Biçim AdıFormat Name | DescriptionDescription |
|---|---|
General Date veya GGeneral Date, or G |
Tarihi ve/veya saati görüntüler.Displays a date and/or time. Örneğin, 3/12/2008 11:07:31 AM.For example, 3/12/2008 11:07:31 AM. Görüntülenen tarih, uygulamanızın geçerli kültür değerine göre değişir.Date display is determined by your application's current culture value. |
Long Date, Medium Date , veya DLong Date, Medium Date, or D |
Geçerli kültürün uzun tarih biçimine göre bir tarih görüntüler.Displays a date according to your current culture's long date format. Örneğin, Wednesday, March 12, 2008.For example, Wednesday, March 12, 2008. |
Short Date veya dShort Date, or d |
Geçerli kültürün kısa tarih biçimini kullanarak bir tarih görüntüler.Displays a date using your current culture's short date format. Örneğin, 3/12/2008.For example, 3/12/2008.dKarakter, günü Kullanıcı tanımlı tarih biçiminde görüntüler.The d character displays the day in a user-defined date format. |
Long Time, Medium Time , veya TLong Time, Medium Time, or T |
Geçerli kültürün uzun saat biçimini kullanarak bir saat görüntüler ve genellikle saat, dakika ve saniye içerir.Displays a time using your current culture's long time format; typically includes hours, minutes, seconds. Örneğin, 11:07:31 AM.For example, 11:07:31 AM. |
Short Time veya tShort Time or t |
Geçerli kültürün kısa saat biçimini kullanarak bir saat görüntüler.Displays a time using your current culture's short time format. Örneğin, 11:07 AM.For example, 11:07 AM.tKarakter, AM PM Kullanıcı tanımlı saat biçiminde 12 saatlik bir saat kullanan yerel ayarların değerlerini veya değerlerini görüntüler.The t character displays AM or PM values for locales that use a 12-hour clock in a user-defined time format. |
f |
Geçerli kültürün biçimine göre uzun tarih ve kısa saati görüntüler.Displays the long date and short time according to your current culture's format. Örneğin, Wednesday, March 12, 2008 11:07 AM.For example, Wednesday, March 12, 2008 11:07 AM. |
F |
Geçerli kültürün biçimine göre uzun tarih ve uzun saat görüntüler.Displays the long date and long time according to your current culture's format. Örneğin, Wednesday, March 12, 2008 11:07:31 AM.For example, Wednesday, March 12, 2008 11:07:31 AM. |
g |
Geçerli kültürün biçimine göre kısa tarih ve kısa saati görüntüler.Displays the short date and short time according to your current culture's format. Örneğin, 3/12/2008 11:07 AM.For example, 3/12/2008 11:07 AM. |
M, mM, m |
Bir tarihin ayını ve gününü görüntüler.Displays the month and the day of a date. Örneğin, March 12.For example, March 12.MKarakter, ayı Kullanıcı tanımlı tarih biçiminde görüntüler.The M character displays the month in a user-defined date format. mKarakter, dakikaları Kullanıcı tanımlı saat biçiminde görüntüler.The m character displays the minutes in a user-defined time format. |
R, rR, r |
Tarihi özelliğe göre biçimlendirir RFC1123Pattern .Formats the date according to the RFC1123Pattern property. Örneğin, Wed, 12 Mar 2008 11:07:31 GMT.For example, Wed, 12 Mar 2008 11:07:31 GMT. Biçimlendirme tarihi, tarih ve saatin değerini ayarlamaz.The formatted date does not adjust the value of the date and time. İşlev çağrılmadan önce tarih/saat değerini GMT olarak ayarlamanız gerekir Format .You must adjust the Date/Time value to GMT before calling the Format function. |
s |
Tarih ve saati sıralanabilir bir dizin olarak biçimlendirir.Formats the date and time as a sortable index. Örneğin, 2008-03-12T11:07:31.For example, 2008-03-12T11:07:31.sKarakter, saniyeyi Kullanıcı tanımlı saat biçiminde görüntüler.The s character displays the seconds in a user-defined time format. |
u |
Tarihi ve saati GMT sıralanabilir bir dizin olarak biçimlendirir.Formats the date and time as a GMT sortable index. Örneğin, 2008-03-12 11:07:31Z.For example, 2008-03-12 11:07:31Z. |
U |
Tarih ve saati GMT ile uzun tarih ve uzun saat biçimlendirir.Formats the date and time with the long date and long time as GMT. Örneğin, Wednesday, March 12, 2008 6:07:31 PM.For example, Wednesday, March 12, 2008 6:07:31 PM. |
Y, yY, y |
Tarihi yıl ve ay olarak biçimlendirir.Formats the date as the year and month. Örneğin, March, 2008.For example, March, 2008.YVe y karakterleri, yılı Kullanıcı tanımlı tarih biçiminde görüntüler.The Y and y characters display the year in a user-defined date format. |
Uygulamanın geçerli kültür bilgileri hakkında daha fazla bilgi için bkz. kültür Visual Basic Içindeki dizeleri nasıl etkiler.For more information about the application's current culture information, see How Culture Affects Strings in Visual Basic.
Kullanıcı Tanımlı Tarih/Saat BiçimleriUser-Defined Date/Time Formats
Aşağıdaki tabloda kullanıcı tanımlı tarih/saat biçimleri oluşturmak için kullanabileceğiniz karakterler gösterilmektedir.The following table shows characters you can use to create user-defined date/time formats. Önceki Visual Basic sürümlerinden farklı olarak, bu biçim karakterleri büyük/küçük harfe duyarlıdır.Unlike in earlier versions of Visual Basic, these format characters are case-sensitive.
| KarakterCharacter | AçıklamaDescription |
|---|---|
(:)(:) |
Tarih ayırıcısı.Time separator. Bazı yerel ayarlarda, saat ayırıcısını temsil etmek için başka karakterler kullanılabilir.In some locales, other characters may be used to represent the time separator. Saat ayırıcısı, saat değerleri biçimlendirilirken saat, dakika ve saniyeleri ayırır.The time separator separates hours, minutes, and seconds when time values are formatted. Biçimlendirilmiş çıktıda saat ayırıcısı olarak kullanılan gerçek karakter, uygulamanızın geçerli kültür değerine göre belirlenir.The actual character that is used as the time separator in formatted output is determined by your application's current culture value. |
(/)(/) |
Tarih ayırıcısı.Date separator. Bazı yerel ayarlarda, tarih ayırıcısını temsil etmek için başka karakterler kullanılabilir.In some locales, other characters may be used to represent the date separator. Tarih ayırıcısı, tarih değerleri biçimlendirilirken gün, ay ve yılı ayırır.The date separator separates the day, month, and year when date values are formatted. Biçimlendirilmiş çıktıda tarih ayırıcısı olarak kullanılan gerçek karakter, uygulamanızın geçerli kültürüne göre belirlenir.The actual character that is used as the date separator in formatted output is determined by your application's current culture. |
(%)(%) |
Takip eden karakterin sonra gelen harflerden bağımsız olarak tek harf biçiminde okunması gerektiğini belirtmek için kullanılır.Used to indicate that the following character should be read as a single-letter format without regard to any trailing letters. Ayrıca tek harfli biçimin kullanıcı tanımlı biçim olarak okunduğunu belirtmek için de kullanılır.Also used to indicate that a single-letter format is read as a user-defined format. Ayrıntılı bilgi için takip eden öğelere bakın.See what follows for additional details. |
d |
Günü önünde sıfır olmadan (örneğin,) bir sayı olarak görüntüler 1 .Displays the day as a number without a leading zero (for example, 1). %dKullanıcı tanımlı sayısal biçiminizdeki tek karakter ise kullanın.Use %d if this is the only character in your user-defined numeric format. |
dd |
Günü önünde sıfır olan bir sayı olarak görüntüler (örneğin, 01 ).Displays the day as a number with a leading zero (for example, 01). |
ddd |
Günü kısaltmayla gösterir (örneğin, Sun ).Displays the day as an abbreviation (for example, Sun). |
dddd |
Günü tam bir ad (örneğin,) olarak görüntüler Sunday .Displays the day as a full name (for example, Sunday). |
M |
Ayı önünde sıfır olmadan bir sayı olarak görüntüler (örneğin, Ocak olarak temsil edilir 1 ).Displays the month as a number without a leading zero (for example, January is represented as 1). %MKullanıcı tanımlı sayısal biçiminizdeki tek karakter ise kullanın.Use %M if this is the only character in your user-defined numeric format. |
MM |
Ayı önünde sıfır (örneğin,) olarak bir sayı olarak görüntüler 01/12/01 .Displays the month as a number with a leading zero (for example, 01/12/01). |
MMM |
Ayı kısaltmayla gösterir (örneğin, Jan ).Displays the month as an abbreviation (for example, Jan). |
MMMM |
Ayı tam ay adı (örneğin,) olarak görüntüler January .Displays the month as a full month name (for example, January). |
gg |
Dönem/dönem dizesini görüntüler (örneğin, A.D. ).Displays the period/era string (for example, A.D.). |
h |
12 saatlik saati (örneğin,) kullanarak saati başta sıfır olmadan bir sayı olarak görüntüler 1:15:15 PM .Displays the hour as a number without leading zeros using the 12-hour clock (for example, 1:15:15 PM). %hKullanıcı tanımlı sayısal biçiminizdeki tek karakter ise kullanın.Use %h if this is the only character in your user-defined numeric format. |
hh |
12 saatlik saati (örneğin,) kullanarak saati önde sıfır olan bir sayı olarak görüntüler 01:15:15 PM .Displays the hour as a number with leading zeros using the 12-hour clock (for example, 01:15:15 PM). |
H |
24 saatlik saati (örneğin,) kullanarak saati başta sıfır olmadan bir sayı olarak görüntüler 1:15:15 .Displays the hour as a number without leading zeros using the 24-hour clock (for example, 1:15:15). %HKullanıcı tanımlı sayısal biçiminizdeki tek karakter ise kullanın.Use %H if this is the only character in your user-defined numeric format. |
HH |
24 saatlik saati (örneğin,) kullanarak saati önde sıfır olan bir sayı olarak görüntüler 01:15:15 .Displays the hour as a number with leading zeros using the 24-hour clock (for example, 01:15:15). |
m |
Dakikayı öndeki sıfırlar olmadan bir sayı olarak görüntüler (örneğin, 12:1:15 ).Displays the minute as a number without leading zeros (for example, 12:1:15). %mKullanıcı tanımlı sayısal biçiminizdeki tek karakter ise kullanın.Use %m if this is the only character in your user-defined numeric format. |
mm |
Dakikayı önünde sıfır olan bir sayı olarak görüntüler (örneğin, 12:01:15 ).Displays the minute as a number with leading zeros (for example, 12:01:15). |
s |
İkincisini önünde sıfır olmadan (örneğin,) bir sayı olarak görüntüler 12:15:5 .Displays the second as a number without leading zeros (for example, 12:15:5). %sKullanıcı tanımlı sayısal biçiminizdeki tek karakter ise kullanın.Use %s if this is the only character in your user-defined numeric format. |
ss |
İkincisini önünde sıfır olan bir sayı olarak görüntüler (örneğin, 12:15:05 ).Displays the second as a number with leading zeros (for example, 12:15:05). |
f |
Saniye kesirleri görüntüler.Displays fractions of seconds. Örneğin ff , saniyenin yüzde biri cinsinden, ffff on-binde/saniye görüntülenir.For example ff displays hundredths of seconds, whereas ffff displays ten-thousandths of seconds. fKullanıcı tanımlı biçiminizdeki en fazla yedi sembol kullanabilirsiniz.You may use up to seven f symbols in your user-defined format. %fKullanıcı tanımlı sayısal biçiminizdeki tek karakter ise kullanın.Use %f if this is the only character in your user-defined numeric format. |
t |
12 saatlik saati kullanır ve A öğleden önce herhangi bir saat için bir büyük harf görüntüler; P öğle ve 11:59 P.M. arasında herhangi bir saat için bir büyük harf görüntülerUses the 12-hour clock and displays an uppercase A for any hour before noon; displays an uppercase P for any hour between noon and 11:59 P.M. %tKullanıcı tanımlı sayısal biçiminizdeki tek karakter ise kullanın.Use %t if this is the only character in your user-defined numeric format. |
tt |
12 saatlik bir saat kullanan yerel ayarlarda, AM öğleden önce herhangi bir saat içeren bir büyük harf görüntüler; PM öğle ve 11:59 P.M. arasında herhangi bir saat içeren bir büyük harf görüntülerFor locales that use a 12-hour clock, displays an uppercase AM with any hour before noon; displays an uppercase PM with any hour between noon and 11:59 P.M.24 saatlik bir saat kullanan yerel ayarlarda hiçbir şey görüntülenir.For locales that use a 24-hour clock, displays nothing. |
y |
Yıl numarasını (0-9) önünde sıfır olmadan görüntüler.Displays the year number (0-9) without leading zeros. %yKullanıcı tanımlı sayısal biçiminizdeki tek karakter ise kullanın.Use %y if this is the only character in your user-defined numeric format. |
yy |
Yılı iki basamaklı sayısal biçimde ve gerekirse önüne sıfır ekleyerek görüntüler.Displays the year in two-digit numeric format with a leading zero, if applicable. |
yyy |
Yılı dört basamaklı sayısal biçimde görüntüler.Displays the year in four-digit numeric format. |
yyyy |
Yılı dört basamaklı sayısal biçimde görüntüler.Displays the year in four-digit numeric format. |
z |
Zaman dilimi sapmasını önünde sıfır olmadan (örneğin, -8 ) görüntüler.Displays the timezone offset without a leading zero (for example, -8). %zKullanıcı tanımlı sayısal biçiminizdeki tek karakter ise kullanın.Use %z if this is the only character in your user-defined numeric format. |
zz |
Saat dilimi sapmasını önünde sıfır ile görüntüler (örneğin, -08 )Displays the timezone offset with a leading zero (for example, -08) |
zzz |
Tam saat dilimi sapmasını görüntüler (örneğin, -08:00 )Displays the full timezone offset (for example, -08:00) |
Eski kod örneğiLegacy Code Example
Aşağıdakiler için Kullanıcı tanımlı tarih ve saat biçimlerinin örnekleri verilmiştir December 7, 1958, 8:50 PM, 35 seconds :The following are examples of user-defined date and time formats for December 7, 1958, 8:50 PM, 35 seconds:
| BiçimlendirFormat | GörüntülenmektedirDisplays |
|---|---|
M/d/yy |
12/7/58 |
d-MMM |
7-Dec |
d-MMMM-yy |
7-December-58 |
d MMMM |
7 December |
MMMM yy |
December 58 |
hh:mm tt |
08:50 PM |
h:mm:ss t |
8:50:35 P |
H:mm |
20:50 |
H:mm:ss |
20:50:35 |
M/d/yyyy H:mm |
12/7/1958 20:50 |
Akıllı Cihaz Geliştirici NotlarıSmart Device Developer Notes
Bir cihaz için en düşük zaman çözümü, cihazın üreticisine göre belirlenir.The minimum time resolution for a device is determined by the manufacturer of the device. Cihaz için zaman çözünürlüğü yeterince kaba ise, f Bu cihazda çalıştırıldığında Biçim karakteri 0 değerini döndürür.If the time resolution for the device is coarse enough, the f format character returns 0 when run on that device.