Excel 2003 スプレッドシートに添付された VBA では、インスタンス化に時間がかかるオブジェクトを使用する必要があるため、「設定」を一度だけ実行したい...
説明を書くよりもコードを見せる方が簡単です!
' Declare the expensive object as global to this sheet
Dim myObj As SomeBigExpensiveObject
Private Sub CommandButtonDoIt_Click()
' Make sure we've got a ref to the object
If IsEmpty(myObj) Then ' this doesn't work!
Set myObj = New SomeBigExpensiveObject
End If
' ... etc
End Sub
myObj が既に設定されているかどうかを確認するにはどうすればよいですか?
IsNull(myObj) と IsEmpty(myObj) を試しました - myObj の状態に関係なく、どちらも「セット」をスキップします。できない
if myObj = Nil then
また
if myObj = Empty then
また
if myObj = Nothing then
何か案は?
SAL