Results 1 to 9 of 9

Thread: How do you reference pre-existing objects from a DLL

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2001
    Location
    Chicago
    Posts
    40

    Question 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?

  2. #2
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Set X = CreateObject("dllname.classname")
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  3. #3
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    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]
    -----------------------------------------

  4. #4
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    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)

  5. #5
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    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...

  6. #6
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Yes it does. You can't declare more than one object/variable in the same scope with the same name.
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  7. #7
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    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..

  8. #8
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Ah, OK. My apologies.
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  9. #9
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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
  •  



Click Here to Expand Forum to Full Width