Такой вопрос:
Есть некий класс C1:
dim c_one as C1
если мы теперь обратимся к методам или свойствам данного класса получим ошибку. Как проверить класс на nothing ?
GSerg писал(а):Осветим вопрос подробнее
Есть функция objptr, возвращающая указатель на объект. Если она даёт NULL (:)), то соответственно
Хотя это наверное знают все?![]()
MSDN писал(а):SUMMARY
It is uncommon for a Visual Basic programmer to need to obtain low level information on a variable, such as its memory address. However, there are some API functions that require such information. This article describes the following Visual Basic functions that may help a Visual Basic programmer obtain this information:
VarPtr - Returns the address of a variable.
VarPtrArray - Returns the address of an array.
StrPtr - Returns the address of the UNICODE string buffer.
VarPtrStringArray - Returns the address of an array of strings.
ObjPtr - Returns the pointer to the interface referenced by an object variable.
MORE INFORMATION
WARNING: One or more of the following functions are discussed in this article; VarPtr, VarPtrArray, VarPtrStringArray, StrPtr, ObjPtr. These functions are not supported by Microsoft Technical Support. They are not documented in the Visual Basic documentation and are provided in this Knowledge Base article "as is." Microsoft does not guarantee that they will be available in future releases of Visual Basic.
ObjPtr
ObjPtr takes an object variable name as a parameter and obtains the address of the interface referenced by this object variable.
One scenario of using this function is when you need to do a collection of objects. By indexing the object using its address as the key, you can get faster access to the object than walking the collection and using the Is operator. In many cases, the address of an object is the only reliable thing to use as a key.
Example:
objCollection.Add MyObj1, CStr(ObjPtr(MyObj1))
...
objCollection.Remove CStr(ObjPtr(MyObj1))
GSerg писал(а):Anyway, Rainbow, с новым тебя званием
Сейчас этот форум просматривают: Google-бот и гости: 2