Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to check that a OLE server was correctly instanciate
Message
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00338617
Message ID:
00338678
Vues:
18
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
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform