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.

傳回 Boolean 值,指出 (Visual Basic) 識別碼是否代表物件 變數。

語法

IsObject ( 識別碼 )

必要的 標識子引數 是變數名稱。

註解

IsObject 在判斷 Variant 是否為 VarTypevbObject 時很有用。 如果 Variant 實際參照 (或一次參照) 物件,或包含 [無內容],就可能會發生這種情況。

如果標識符是以 物件 類型或任何有效的 類別 類型宣告的變數,或標識符VarTypevbObjectVariant 或使用者定義的物件,IsObject 會傳回 True;否則,它會傳回 False。 即使變數設定為 [無]IsObject 仍會傳回 True

使用錯誤捕捉來確認物件參照有效。

範例

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

此範例使用 IsObject 函數來判斷標識碼是否代表物件變數。 MyObjectYourObject 是相同類型的物件變數。 它們是僅供圖例使用的一般名稱。

' Declare variables.
Dim MyInt As Integer, YourObject, MyCheck
Dim MyObject As Object
Set YourObject = MyObject ' Assign an object reference.
MyCheck = IsObject(YourObject) ' Returns True.
MyCheck = IsObject(MyInt) ' Returns False.

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!

×