1.11M Members

Creating a VB dll

 
0
 

I am researching how to create a dll in VB..can it even be done? Does anyone know of any sites or books that can help me through this process?

 
0
 

I'm sure if you google it, there is 1 or 2. The problem is this, though. The dll's that you create with VB are not "true dll's", they are "activeX dll's", and it's sort of complicated, but it has to due with "Entry Points". So, if you need to "up your search" on google, do a search for say: +"visual basic" +"activex dll" on google.... maybe it will come up with something.

 
0
 

hi,

1. in vb dlls are created with application type ActiveX dll. (select as new project -->open it)
2. u will get one class window opened.
3. u can write code in this window.
4. in project menu-->refferences
add refference to COM+ Serviece Type library.
5. for using with ADO. u need to add
microsoft activex data object library 2.5

6. set propertys of class module.
instance property - 5- multy use
mts transactionmode --> 2 RequiresTransaction
7. write following code (sample)

Public Function GetServerDate() As Date
On Error GoTo errlbl
Dim objCont As COMSVCSLib.ObjectContext
Set objCont = GetObjectContext

GetServerDate = Date
objCont.SetComplete
Set objCont = Nothing
Exit Function
errlbl:
' if we need can add log method here
objCont.SetAbort
Set objCont = Nothing
End Function

Public Function GetServerServerTime() As String
On Error GoTo errlbl
' { common for every dll
Dim objCont As COMSVCSLib.ObjectContext
Set objCont = GetObjectContext
''}
''----------------------------
' general program here. like in class module
GetServerServerTime = Time
''-----------------------------
''{ common to dll
objCont.SetComplete
Set objCont = Nothing
''}
Exit Function
'{optional}
errlbl:
' if we need can add log method here
objCont.SetAbort
Set objCont = Nothing
End Function

8. in project menu --> component tab.
select project compatability option(default)
(study abt compatability by clicking the help button in this dailog box(u can get info in less time else go for google
imp: first time u creating a dll default is correct( new GUID is created, study more abt guid in help. imp2: when u modifing code in dll. select binary compatability) )

click OK.
If u r developing dll for 3 tire architecture. u need to select server files check box.

9. then file --> make .dll.

10. open control panel->compnent services
console root->comp services-> my computers>com+ applictions
right click -> new application ->next-> select create emply application>enter new app name, select library app opt. if not server 3tire app.-> next ->finish

11. u will get a new app name in tree view. click on +
right click on components > new > component > next > select install new components > select dll file name > open > next > finish
(by drag drop also we can do it, check help for more info)
12. now u will get new dll added in component services explore.
--------------
13. now open standard vb appliction
place 2 text boxs, 2 buttons

peast following code.
Private Sub Command1_Click()
Dim obj As Dll_co_common.ClsCommon
Set obj = CreateObject("Dll_co_common.ClsCommon")
Text1.Text = obj.GetServerServerdate
Set obj = Nothing
End Sub

Private Sub Command2_Click()
Dim obj As Dll_co_common.ClsCommon
Set obj = CreateObject("Dll_co_common.ClsCommon")
Text2Text = obj.GetServerServerTime
Set obj = Nothing
End Sub

14. add refference to dll.
project menu>refferences
check new dll file name, if not found browes to add new dll to add to refference list.

15. now run ur client program.

u can also develop for database programs also.
my suggestion is go throug help in vb(msdn) dailog box, dont spend for more time to search for concept itself.
i think it will help u, for atleast starting of dll coding.
if it is not enough for ur requirement use keywork from the program to search in online sources
enjoy vb programming .... all the best my friend

 
0
 

Does anyone know if you can create a non activeX dll, or if an ActiveX dll can be called like a regular dll from a c++ program?

 
0
 

Yes, U definitely can. And it is very easy. Just open your project as an active X dll project and you are on your way! Of course you have to be certain what you want to do.

 
0
 

Hello I am new to this DLL stuff and I am not able to find the "compnent services" that you have mentioned in the control panel ..could you just tell me if the name has been changed or some thing like that?

 
0
 

This depends on the operating system you are using and I believe there is not much difference across systems. I am using windows 2000 adv. server. The component services can be seen after clicking "administrative tools" icon. Component services is one of the icons that is displayed if you look closely.;)

Hello I am new to this DLL stuff and I am not able to find the "compnent services" that you have mentioned in the control panel ..could you just tell me if the name has been changed or some thing like that?

 
0
 

Yes, Yes my dear:!:
That is the power of the ActiveX technology.
You can call the activeX dll from c++ like any other dll with the following proviso.

  • you have to register the created ActiveX dll on your machine using regsvr32.exe command
  • you have to reference the dll in your c++ project
  • thereafter make method calls to it like any other dll

comprende?;)

Does anyone know if you can create a non activeX dll, or if an ActiveX dll can be called like a regular dll from a c++ program?

 
0
 

I am researching how to create a dll in VB..can it even be done? Does anyone know of any sites or books that can help me through this process?

Yes - Using VB dot Net

 
0
 

for using the
---Dim obj As Dll_co_common.ClsCommon
---Set obj = CreateObject("Dll_co_common.ClsCommon")
in the code that srikanthvja; had given do we need to add some more reference to the project to make it working

I was getting a run time error in the above two lines of code

hi,

1. in vb dlls are created with application type ActiveX dll. (select as new project -->open it)
2. u will get one class window opened.
3. u can write code in this window.
4. in project menu-->refferences
add refference to COM+ Serviece Type library.
5. for using with ADO. u need to add
microsoft activex data object library 2.5

6. set propertys of class module.
instance property - 5- multy use
mts transactionmode --> 2 RequiresTransaction
7. write following code (sample)

Public Function GetServerDate() As Date
On Error GoTo errlbl
Dim objCont As COMSVCSLib.ObjectContext
Set objCont = GetObjectContext

GetServerDate = Date
objCont.SetComplete
Set objCont = Nothing
Exit Function
errlbl:
' if we need can add log method here
objCont.SetAbort
Set objCont = Nothing
End Function

Public Function GetServerServerTime() As String
On Error GoTo errlbl
' { common for every dll
Dim objCont As COMSVCSLib.ObjectContext
Set objCont = GetObjectContext
''}
''----------------------------
' general program here. like in class module
GetServerServerTime = Time
''-----------------------------
''{ common to dll
objCont.SetComplete
Set objCont = Nothing
''}
Exit Function
'{optional}
errlbl:
' if we need can add log method here
objCont.SetAbort
Set objCont = Nothing
End Function

8. in project menu --> component tab.
select project compatability option(default)
(study abt compatability by clicking the help button in this dailog box(u can get info in less time else go for google
imp: first time u creating a dll default is correct( new GUID is created, study more abt guid in help. imp2: when u modifing code in dll. select binary compatability) )

click OK.
If u r developing dll for 3 tire architecture. u need to select server files check box.

9. then file --> make .dll.

10. open control panel->compnent services
console root->comp services-> my computers>com+ applictions
right click -> new application ->next-> select create emply application>enter new app name, select library app opt. if not server 3tire app.-> next ->finish

11. u will get a new app name in tree view. click on +
right click on components > new > component > next > select install new components > select dll file name > open > next > finish
(by drag drop also we can do it, check help for more info)
12. now u will get new dll added in component services explore.
--------------
13. now open standard vb appliction
place 2 text boxs, 2 buttons

peast following code.
Private Sub Command1_Click()
Dim obj As Dll_co_common.ClsCommon
Set obj = CreateObject("Dll_co_common.ClsCommon")
Text1.Text = obj.GetServerServerdate
Set obj = Nothing
End Sub

Private Sub Command2_Click()
Dim obj As Dll_co_common.ClsCommon
Set obj = CreateObject("Dll_co_common.ClsCommon")
Text2Text = obj.GetServerServerTime
Set obj = Nothing
End Sub

14. add refference to dll.
project menu>refferences
check new dll file name, if not found browes to add new dll to add to refference list.

15. now run ur client program.

u can also develop for database programs also.
my suggestion is go throug help in vb(msdn) dailog box, dont spend for more time to search for concept itself.
i think it will help u, for atleast starting of dll coding.
if it is not enough for ur requirement use keywork from the program to search in online sources
enjoy vb programming .... all the best my friend

 
0
 

Yes - Using VB dot Net

yeah, be cheap and use VB express if you have to.

Its much easier in .NET but bear in mind that they are still not true dlls either as they need the .NET CLR

 
0
 

Follow those steps.
1. start with "basic dll example" using OREILLY's well documented article (following link) http://windowsdevcenter.com/pub/a/windows/2005/04/26/create_dll.html

2. once done (1) you are 70% done.
finish- by tuning up using Mathimagics Manual of "Advanced VB6 DLL Construction".

3. 1,2 will bring you the the point of having a readable Dynamic Link Lib. File, fully readable by C/.Net and so.., since the functions declared are compatible using a standard Entry Point and formal functions (subs..) name declaration. Its simpler then it sounds. You will master those simple tasks in no time :)
http://www.xtremevbtalk.com/showthread.php?t=282796

EladKarako

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article