Results 1 to 7 of 7

Thread: need help to write dll

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2008
    Posts
    198

    need help to write dll

    hi all
    i need help:
    i want to write dll using vb6. i dont know the rules to write dll.
    can anyone help me write asimple dll.
    anything. i just want to know how to start write dll in the vb6 and how to call that dll function
    thanx

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: need help to write dll

    1. Create new project
    2. Go to File menu and select "Add Project"
    3. From the dilaog select "ActiveX Dll"
    4. In the main project go to Project > References and set references to Project2 (I kept project names as default so change Project2 to whatever name you might have)
    5. Add the following code to your Class1 in the dll project
    Code:
    Public Function CalcResult(a As Long, b As Long) As Long
        CalcResult = a + b
    End Function
    6. Add the following code to your Form1 code window in the main project:
    Code:
    Private Sub Command1_Click()
    Dim myDll As Project2.Class1
    
        Set myDll = New Project2.Class1
        MsgBox myDll.CalcResult(10, 20)
    
    End Sub
    7. Run main project and click on the button.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: need help to write dll

    That is a start.

    Now, what do you want it to do?

  4. #4
    Addicted Member
    Join Date
    Oct 2004
    Location
    Israel the holy land
    Posts
    160

    Re: need help to write dll

    RhinoBull as much as i understand you can write DLL's that when you put them in the COM+, some will work under Library in the COM+ and some under Server. why?what is the diffrence between the DLL's that installed under Library or under the Server
    Israel - the best place to live in after heaven, but no one want's to go there so fast.

    http://www.networked-toys.com/
    http://www.nirlat.com/home_page.asp

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2008
    Posts
    198

    Re: need help to write dll

    nice i creat that dll sample
    and now i have "AplusB.dll".
    how can i include this dll file to another vb6 project "standart windows form"
    and how can i call it
    thanx....

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: need help to write dll

    add a reference to the dll, in your std project, declare a variable and set the variable to the dll class
    see item 6 in rhinobull post above
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: need help to write dll

    If may use activex dll in your project without referencing it - it's called "Late Binding":

    Set myDll = CreateObject("MyDll.MyClass")

    The only thing is dll must be registered so you'd have to distribute it with every project that needs 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