• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

Creating a DLL file

How do I create a dll file some sample code would be nice.
thank you.

You can email me at sear@nastything.com
  • 2
  • 2
  • 2
  • +3
1 Solution
It's time for you to move to a new programming lenguaje such as Delphi or C++. Unfortunately you can't create DLL's in VB. ... By now you'll be saying "That's not true, on the VB compiler there are options to make DLL's".... And It's true, but those are ActiveX DLL's, this means that you can't store in a DLL normal functions (even as they are as simple to just add two numbers).
Trillo, is right. Please answer the question.
Oeps, mistake, reject mine please.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

nice answer trillo?!. DLL=activeX
In VB you can use activeX DLL or Document DLL, MSDN (on microsoft site) explains!
Windows is made by VB so nothing Delphi...
You don't have to write DLLs using C++ or Delphi !

You can write DLLs in BASIC using PowerBASIC's DLL Compiler. I have used their product in several apps, its fast and simple. The transition was painless and their DLLs are not ActiveX DLLs.

To Gertt
>> Windows is made by VB
  Windows is made by VB?......Wrong!.... Windows is mostly mado by C++
>> In VB you can use activeX DLL or Document DLL, MSDN (on microsoft site) explains!
  cwrjr is asking how to CREATE DLL's in VB not if he can use them.

To dm_14
I didn't say you MUST use C++ or Delphi, I said languages SUCH AS C++ or Delphi.
cwrjrAuthor Commented:
no solution
Start VB5 and select ActiveX Dll for a project.

Rename Project to ProjTest

Under properties select Unattended Execution, Apartment Threading Model.

Rename Class1 to cTest

Add the Following code to the class module.

Option Explicit

Public function ReturnTxt() as String
  ReturnTxt="This is a text string from a DLL"
end function

public sub AddTxt(psText as string)
dim lsTemp as string

  lsTemp=psText & " Added Text"
end sub

public function AddNumbers(liNum1 as integer, liNum2 as integer) as integer
end function

Run the project to make sure you have no errors. If no erros then compile into dll.

Start a new Standard EXE project in VB5.

Rename Project1 to ProjMain

Under Project references select ProjTest

Place 3 texboxes on the form called txtTest1, txtTest2, txtTest3.
Place 3 commandbuttons on the form called cmdTest1, cmdTest2, cmdTest3.

Place the following code in the forms code window.

Option Explicit

Private cTest As cTest

Private Sub cmdTest1_Click()
  txtTest1 = cTest.ReturnTxt
End Sub

Private Sub cmdTest2_Click()
Dim lsTemp As String
  lsTemp = txtTest2.Text
  Call cTest.AddTxt(lsTemp)
  txtTest2 = lsTemp
End Sub

Private Sub cmdTest3_Click()
  txtTest3 = cTest.AddNumbers(2, 4)
End Sub

Private Sub Form_Load()
  Set cTest = New cTest
  txtTest1 = ""
  txtTest2 = "Original Text"
  txtTest3 = ""
  cmdTest1.Caption = "ReturnTxt"
  cmdTest2.Caption = "AddText"
  cmdTest3.Caption = "AddNum"
End Sub

cwrjrAuthor Commented:
Thank you
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now