Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_components thread: VB Components


Message #1 by "deji oye-somefun" <dejji@h...> on Thu, 07 Dec 2000 17:54:34 -0000
I notice  com programs sometimes use New and then sometimes not.I understand 

the new syntax to return the reference of an object with C++ I think this is 

the same with VB however some times vbCom's do not use New  ,I've read that 

they do not need this if the COM object  is provided within the same Dll, 

but then again I've come across programs that use this syntax

Dim Confused AS Explain.Please

Set Confused = CreateObject("Explain.Please")



Why the CreateObject couldnt we just go ahead and say

Set Confused = Explain.Please or just use it without the create object bit 

Since in this case Explain.Please exists within the same Dll

Another things why do they sometimes use

Dim objConn AS ADODB.Connection

Set objConn = New ADODB.Connection



and then sometimes omit the

Set objConn = New ADODB.Connection

I would really like to clear this up..

Thankyou





_____________________________________________________________________________________

Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com



Message #2 by ssteward@a... on Thu, 7 Dec 2000 12:08:14 -0600
If you use Set Confused = New Explain.Please, you must have a reference to

Explain in your vb project.  This makes it early bound, meaning it actually

creates the object ahead of time and it is more efficient.  However, if you

run your component on another machine that doesn't have the exact same

version of that Component, you could run into errors and it won't work at

all.  The only time you want to early bind to an object is if you're sure it

will not change on you.  Using CreateObject("Explain.Please") will work with

whatever version of the component is on the machine, granted that it still

has the same functions and parameters...



Set Closing = Hope.This(Helps)



shawn



-----Original Message-----

From: deji oye-somefun [mailto:dejji@h...]

Sent: Thursday, December 07, 2000 8:13 PM

To: ASP components

Subject: [asp_components] VB Components





I notice  com programs sometimes use New and then sometimes not.I understand



the new syntax to return the reference of an object with C++ I think this is



the same with VB however some times vbCom's do not use New  ,I've read that 

they do not need this if the COM object  is provided within the same Dll, 

but then again I've come across programs that use this syntax

Dim Confused AS Explain.Please

Set Confused = CreateObject("Explain.Please")



Why the CreateObject couldnt we just go ahead and say

Set Confused = Explain.Please or just use it without the create object bit 

Since in this case Explain.Please exists within the same Dll

Another things why do they sometimes use

Dim objConn AS ADODB.Connection

Set objConn = New ADODB.Connection



and then sometimes omit the

Set objConn = New ADODB.Connection

I would really like to clear this up..

Thankyou

Message #3 by dejji@h... on Mon, 11 Dec 2000 17:40:55 -0000
Okay so if I have a reference to the object then I can use New. To

determine if I have a reference does that mean in VB just adding a

reference to the project? If I dont have a reference do I then have to use

createobject() function?


  Return to Index