|
-
Aug 27th, 2000, 04:02 PM
#1
Thread Starter
Hyperactive Member
Hi! I am making a MS Internet Transfer Control in code and I would like to know what is the difference between
Set Inet = CreateObject("InetCtls.Inet")
and
Set Inet = New InetCtlsObjects.Inet
with adding reference to the control.
============================================================
When I try to use commF = Inet.OpenURL("[address]", icByteArray), it returns commF(0 to -1), but the file exists. Where is the problem?
Thanks,
John
-
Aug 27th, 2000, 04:18 PM
#2
Fanatic Member
In answer to your first question.
If you use "CreateObject" with no refernce to the dll that contains the inet control, then you will get late binding.
If you add a refernce to the dll, and dim all the variables as the correct type, then you will get early binding.
Early binding is quicker than late binding, as with late binding your app has to mnake sure that each of the properties / methods you have used actually exist. If you have early binding, this is all done when compiling, so the code runs that much quicker.
Iain, thats with an i by the way!
-
Aug 27th, 2000, 04:25 PM
#3
Fanatic Member
Plus, if you use CreateObject, you will not get the drop down box because it has no reference to dll. When I say drop down box, I mean like the properties and methods that comes with that application.
Iain is right, Early binding is faster than Late binding.
The only time I use CreateObject, is when I only want to save as form and don't want the VBP file.
If you use GetObject on the other hand, you must reference as a Early Binding.
Chemically Formulated As:
Dr. Nitro
-
Aug 27th, 2000, 04:54 PM
#4
No, you will sertanly get the "drop down" even if you use CreateObject. You will not get it however if you use late bindings. CreateObject can be used without using late bindings.
Here's an example that uses early bindings with CreateObject:
Code:
Private myObj As CMyClass
Private Sub Form_Load()
Set myObj = CreateObject("MyDll.CMyClass")
End Sub
This is early bindings because myObj is declared as a special object and not as the Object type.
CreateObject is slower then using the New keyword though.
Because when you use CreateObject your application has to look up the UUID key in the registry during run-time. While using the New keyword the UUID key is looked up during the compile of the app and is compiled into the EXE.
Best regards
-
Aug 27th, 2000, 05:52 PM
#5
Fanatic Member
Sorry!
What I meant was if you did not reference the dll and do something like this, you will not get the drop down menu.
Code:
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Visible = True
Chemically Formulated As:
Dr. Nitro
-
Aug 27th, 2000, 07:06 PM
#6
I understood that that was what you meant. I just wanted to clarify that using CreateObject isn't nessasary the same as late binding.
In your example you use late binding because you declare xlApp as object. You do need to use CreateObject with late bound objects though. The New keyword is only valid with early bound objects.
-
Aug 28th, 2000, 09:25 AM
#7
Thread Starter
Hyperactive Member
If I want the dropmenus, I can add a reference to the DLL only temporaly and then remove it.
I meaned some more essential reasons...
For example. Is my program able to run if it has a reference to the dll, but the dll is not on the computer?
(If I use CreateObject I can handle the error..)
-
Aug 28th, 2000, 09:34 AM
#8
You can catch the error even if you use the New keyword.
The only requriments is that you have the COM object installed and registred on your computer when you compile the project.
Code:
'this use early binding and it will not
'compile if CMyClass doesn't exist on the
'computer that makes the compilation
'The EXE will however run on a computer that
'lacks the CMyClass object
Private o As CMyClass
Private Sub Form_Load()
On Error Resume Next
Set o = New CMyObject
If Err Then
'CMyObject is missing or is not registred proparly
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|