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.

附註: 如果 Microsoft Jet Expression Service 在沙箱模式中執行,會停用本主題中所述的函數、方法、物件或屬性,以免評估可能不安全的表達式。 如需沙盒模式的詳細資訊,請在 [說明] 中搜尋「沙盒模式」。

傳回對應到指定 錯誤編號的錯誤訊息。

語法

錯誤 [ (錯誤編號) ]

選擇性 錯誤編號引數 可以是任何有效的錯誤編號。 如果 errornumber 是有效的錯誤數位,但並未定義, Error 會傳回字串「Application-defined 或物件定義錯誤」。 如果 errornumber 無效,則會發生錯誤。 如果省略 錯誤編號 ,會傳回對應至最新 執行階段錯誤 的郵件。 如果未發生運行時間錯誤,或錯誤編號為 0,Error 會傳回零長度字串 (“”) 。

註解

檢查 Err 物件的 屬性 設定,以找出最新的運行時間錯誤。 Error 函數的傳回值會對應到 Err 物件的 Description 屬性。

範例

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

此範例使用 Error 函數來列印對應到指定錯誤數位的錯誤訊息。

Dim ErrorNumber
' Loop through values 61 - 64.
For ErrorNumber = 61 To 64
' Print error to Immediate window.
Debug.Print Error(ErrorNumber)
Next ErrorNumber

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!

×