PowerApps 中的 Value 函式Value function in PowerApps

將文字字串轉換為數字。Converts a string of text to a number.

說明Description

Value 函式會將包含數字字元的文字字串轉換為數字值。The Value function converts a string of text that contains number characters to a number value. 當您需要對使用者以文字形式輸入的數字執行計算時,請使用此函式。Use this function when you need to perform calculations on numbers that were entered as text by a user.

不同語言對 .Different languages interpret , and . 有不同的解釋。differently. 根據預設,系統會使用目前使用者所用的語言來解釋文字。By default, the text is interpreted in the language of the current user. 您可以使用 Language 函式所傳回的相同語言標記,來指定要對語言標記使用的語言。You can specify the language to use with a language tag, using the same language tags that are returned by the Language function.

字串格式的注意事項︰Notes on the format of the string:

  • 此字串前面可能會加上目前語言的貨幣符號。The string may be prefixed with the currency symbol for the current language. 此貨幣符號會遭到忽略。The currency symbol is ignored. 其他語言的貨幣符號則不會遭到忽略。Currency symbols for other languages are not ignored.
  • 此字串的結尾可能會加上百分比符號 (%),以表示它是百分比。The string may be include a percent sign (%) at the end, indicating that it is a percentage. 該數字會先除以 100 再傳回。The number will be divided by 100 before being returned. 百分比和貨幣符號不能混用。Percentages and currency symbols cannot be mixed.
  • 字串可能會使用科學記號標記法,將 12 x 103 表示為 "12e3"。The string may be in scientific notation, with 12 x 103 expressed as "12e3".

如果數字的格式不正確,Value 會傳回「空白」。If the number is not in a proper format, Value will return blank.

若要轉換日期和時間值,請使用 DateValueTimeValueDateTimeValue 函式。To convert date and time values, use the DateValue, TimeValue, or DateTimeValue functions.

語法Syntax

Value( String [, LanguageTag ] )Value( String [, LanguageTag ] )

  • String - 必要項目。String - Required. 要轉換為數值的字串。String to convert to a numeric value.
  • LanguageTag - 選擇性項目。LanguageTag - Optional. 用來剖析字串的語言標記。The language tag in which to parse the string. 若未指定,系統會使用目前使用者所用的語言。If not specified, the language of the current user is used.

範例Examples

執行這些公式的使用者位於美國,並選取英文做為語言。The user running these formulas is located in the United States and has selected English as their language. Language 函式會傳回「en-US」。The Language function is returning "en-US".

公式Formula 說明Description 結果Result
Value( "123.456" )Value( "123.456" ) 系統會使用預設語言 "en-US",其使用句點作為小數分隔符號。The default language of "en-US" will be used, which uses a period as the decimal separator. 123.456123.456
Value( "123.456", "es-ES" )Value( "123.456", "es-ES" ) "es-ES" 是西班牙的西班牙文語言標記。"es-ES" is the language tag for Spanish in Spain. 在西班牙,句點是千位分隔符號。In Spain, a period is a thousands separator. 123456123456
Value( "123,456" )Value( "123,456" ) 系統會使用預設語言 "en-US",其使用逗號作為千位分隔符號。The default language of "en-US" will be used, which uses a comma as a thousands separator. 123456123456
Value( "123,456", "es-ES" )Value( "123,456", "es-ES" ) "es-ES" 是西班牙的西班牙文語言標記。"es-ES" is the language tag for Spanish in Spain. 在西班牙,逗號是小數分隔符號。In Spain, a comma is the decimal separator. 123.456123.456
Value( "12.34%" )Value( "12.34%" ) 字串結尾的百分比符號表示這是百分比。The percentage sign at the end of the string indicates that this is a percentage. 0.12340.1234
Value( "$ 12.34" )Value( "$ 12.34" ) 目前語言的貨幣符號會遭到忽略。The currency symbol for the current language is ignored. 12.3412.34
Value( "24e3" )Value( "24e3" ) 12 x 103 的科學記號標記法。Scientific notation for 12 x 103. 2400024000