Results 1 to 12 of 12

Thread: [RESOLVED] How to call dll ?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] How to call dll ?

    I have create the dll from VB6. my dll name is "Project1"

    So how I can use the dll I have created such as call the form from command button through the dll.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How to call dll ?

    Go to "Project" -> "References", tick the box next to the DLL, and press OK.

    Then add code like this:
    Code:
    Dim MyObject as Project1.Class1
      Set MyObject = New Project1.Class1
    
      'code to work with MyObject
    
      Set MyObject = Nothing
    You need to replace Project1 with whatever code name you gave your DLL, and Class1 with a class that it exposes (they will be listed when you type the . )

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: How to call dll ?

    I got the error message while adding in References

    For this line "'code to work with MyObject". What is the example?
    Attached Images Attached Images  

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How to call dll ?

    The error means that the library name you chose for the DLL isn't unique - you have another item in your project (or even the project itself) which has the same name (which you set under "Project" -> "Properties"). Give the DLL a name which is unique, and try again.

    As to the "'code to work with MyObject" part, that is entirely dependent on the code in your DLL - but would be the same as if you were using the class directly in the same project.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: How to call dll ?

    This is the first time I used dll.

    I have design the form1,form2 and also name the class1 and save it as project2

    But How I can access the form in the class? I can see the class1 list. I also add it as reference.But When typing MyObject , the from1 and form2 not listed. How to list it? hopes learning from the sample attach file from you

    Dim MyObject As Project2.Class1
    Set Myobject = New Project2.Class1

  6. #6
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Re: How to call dll ?

    Compile the DLL project and create a .dll file.Add this .dll as a reference to your project.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: How to call dll ?

    I have done it. I don't know what wrong.

    Could you attach me one sample and put one form and one class. I would like to look why my form not list.

  8. #8
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Re: How to call dll ?

    Could you post the sample code ? I'm not sure about your requirement.

    You have one project with a form and class .And you want to access the form in the class ?

  9. #9
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888
    Quote Originally Posted by matrik02
    Yes.
    Here is a sample attached .Hope this helps.

    Quote Originally Posted by martrik02
    Ok, Then how to access it.
    Attached Files Attached Files
    Last edited by si_the_geek; Apr 29th, 2008 at 11:50 AM. Reason: accidentally merged - sorry!! "quote" parts should be (and were) separate posts

  10. #10
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Re: How to call dll ?

    ?? I'm not sure of the question.In the class1.cls is accessing form1

    Could you post the sample code that you have implemented ?

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: How to call dll ?

    Sorry,

    Actually I would like to create the dll from your sample.

    Then I open another project, I add your dll as reference and would like to showed the form when I click the button on the form I design. Something like that.

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: How to call dll ?

    Quote Originally Posted by amrita
    ?? I'm not sure of the question.In the class1.cls is accessing form1

    Could you post the sample code that you have implemented ?
    Thank you, I work now. Hi, I have modify your code. I put the function in the class. Thank you both of you

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