Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

會傳回代表數字的 Variant (String)。

語法

Str ( 數字 )

必要 數位引數 為 Long,包含任何有效的 數值運算式。

註解

當數字轉換成字串時,一律會保留前置空格做為 數字符號。 如果 number 是正數,傳回的字串會包含前置空格,並隱含加號。

使用 Format 函數來轉換您要格式化為日期、時間或貨幣或其他使用者定義格式的數值。 與 Str 不同Format 函數不包含 數位符號的前置空格。

附註:  Str 函數只會辨識句號 () 為有效的小數分隔符。 例如,當國際應用程式) 使用不同的小數分隔符 (時,請使用 CStr 將數位轉換成字串。

查詢範例

Expression

結果​​

SELECT Discount,str (Discount) AS StrDiscount FROM ProductSales;

傳回原始的「折扣」值/格式,以及在欄 StrDiscount 中轉換為字串格式的值。

VBA 範例

附註: 下列範例示範如何在 Visual Basic for Applications (VBA) 模組中使用此函數。 如需使用 VBA 的詳細資訊,請在 [搜尋] 旁的下拉式清單中選取 [開發人員參考],並在 [搜尋] 方塊中輸入一個或多個字詞。

此範例使用 Str 函數傳回數位的字串表示。 當數字轉換成字串時,一律會保留前置空格做為其符號。

Dim MyString
MyString = Str(459) ' Returns " 459".
MyString = Str(-459.65) ' Returns "-459.65".
MyString = Str(459.001) ' Returns " 459.001".

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×