|
-
Aug 14th, 2002, 09:56 PM
#1
Thread Starter
Member
How do you reference pre-existing objects from a DLL
Desperate, need Help! I can't figure out to reference an already created object.
Here's what I did. I created a DLL with a form(frmWsk) and a class module (Smtp).
I defined a bunch of public properties and one method in my class:
'Class module(Smtp.cls) in Active X DLL
Private ServerData As String
Public Property Let Server(ByVal Data As String)
ServerData = Trim(Data)
End Property
Public Property Get Server() As String
Server = ServerData
End Property
'a bunch more and then my method
Public Sub Sendmail()
frmWsk.Form_Load
End Sub
'Form (frmWsk.frm) in Active X DLL
Private Test As Smtp
Public Sub Form_Load()
Set Test = Smtp
Msgbox Test.Server
End sub
'Code calling compiled Active X DLL
Public Smtp As Smtp
Sub main()
Set Smtp = New Smtp
With Smtp
.Server = "test.com"
.Sendmail
End With
I get error 424 object required. How do should I reference the object created in code calling the DLL?
End Sub
Any ideas?
-
Aug 14th, 2002, 10:04 PM
#2
PowerPoster
Set X = CreateObject("dllname.classname")
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Aug 14th, 2002, 10:05 PM
#3
PowerPoster
To use the New keyword, your .dll needs to provide internal instancing, and I haven't the foggiest of where to start to make that work. CreateObject is a little slower, but you gotta make sacrifices sometimes.
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Aug 14th, 2002, 10:40 PM
#4
First:
Public Smtp As Smtp
If Smtp is a valid object, you cannot make a variable by the same name.
Finally, try using the CDONTS library for sending mail if you are on an e-mail enabled server, or the OUTLOOK object if you are on outlook, or you will need to find a custom smtp object.
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Aug 15th, 2002, 01:35 AM
#5
Frenzied Member
Originally posted by Lord_Rat
First:
Public Smtp As Smtp
If Smtp is a valid object, you cannot make a variable by the same name.
It doesn't make any difference Lord_Rat..
See the Node_Click Event Handler of TreeView...
-
Aug 15th, 2002, 04:42 AM
#6
PowerPoster
Yes it does. You can't declare more than one object/variable in the same scope with the same name.
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Aug 15th, 2002, 08:31 AM
#7
Frenzied Member
You cannot have more than one Variable in the same scope I agree... But i thought it was all about the names of Class and Object. My point is; an object can have the same name as that of its class..
-
Aug 15th, 2002, 05:27 PM
#8
PowerPoster
Ah, OK. My apologies.
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Aug 15th, 2002, 06:15 PM
#9
Did you add a reference to the dll in your project that you want to use it? Did you say that and I missed it?
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
|