Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to check that a OLE server was correctly instanciate
Message
From
28/02/2000 16:06:32
 
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00338617
Message ID:
00338678
Views:
16
Thanks for your reply Éric, I've modified my code to use the method you've showed.

Is there another way of verifying that the DLL instanciated correctly other than using On Error? In VFP, I would do the following:
loDLL = NewObject("DEXLink.DEXLink")

IF VarType(loDLL) <> "O"
   *-- Error message goes here
ENDIF
In VB, I get an error on the second line:
Dim loUtility As dexutility.dexutility   '<-- OK
Set loUtility = New dexutility.dexutility   '<-- Error
TIA
>Declaration like you do reports creating the instance until you really use it.
>
>For example, if you have this code:
>
>Dim loUtility As New dexutility.dexutility
>
>   loUtility.Prop = 1
>
>
>The instance is not created until you assign something to the property or call a method. The best proof of this is to place a MsgBox in the Class_Initialize event and check when it will be triggered.
>
>I want to say that it is not recommanded to use the syntax you use because VB have to check if the instance is created or not on each object use. So this code:
>
>Dim loUtility As New dexutility.dexutility
>
>   loUtility.Prop1 = 1
>   loUtility.Prop2 = 1
>   loUtility.Prop3 = 1
>
>
>Is compiled this way:
>
>Dim loUtility As New dexutility.dexutility
>
>   If loUtility Is Nothing then
>      Set loUtility = new dexutility.dexutility
>   End If
>   loUtility.Prop1 = 1
>   If loUtility Is Nothing then
>      Set loUtility = new dexutility.dexutility
>   End If
>   loUtility.Prop2 = 1
>   If loUtility Is Nothing then
>      Set loUtility = new dexutility.dexutility
>   End If
>   loUtility.Prop3 = 1
>
>
>The recommanded way is this one:
>
>Dim loUtility As dexutility.dexutility
>
>   Set loUtility = new dexutility.dexutility
>   loUtility.Prop1 = 1
>   loUtility.Prop2 = 1
>   loUtility.Prop3 = 1
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform