Creating a VB dll

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2004
Posts: 1
Reputation: snostar is an unknown quantity at this point 
Solved Threads: 0
snostar snostar is offline Offline
Newbie Poster

Creating a VB dll

 
0
  #1
Jan 21st, 2005
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?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Creating a VB dll

 
0
  #2
Jan 21st, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 7
Reputation: srikanthvja is an unknown quantity at this point 
Solved Threads: 0
srikanthvja srikanthvja is offline Offline
Newbie Poster

Re: Creating a VB dll

 
0
  #3
Feb 7th, 2005
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
Last edited by srikanthvja; Feb 7th, 2005 at 1:28 am. Reason: not yet completed editing, sory for inconvinence
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 28
Reputation: mjwest10 is an unknown quantity at this point 
Solved Threads: 3
mjwest10 mjwest10 is offline Offline
Light Poster

Re: Creating a VB dll

 
0
  #4
Mar 27th, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 216
Reputation: jamello is an unknown quantity at this point 
Solved Threads: 6
jamello's Avatar
jamello jamello is offline Offline
Posting Whiz in Training

Re: Creating a VB dll

 
0
  #5
Apr 3rd, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 2
Reputation: Bejoyjohn is an unknown quantity at this point 
Solved Threads: 0
Bejoyjohn Bejoyjohn is offline Offline
Newbie Poster

Re: Creating a VB dll

 
0
  #6
Apr 6th, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 216
Reputation: jamello is an unknown quantity at this point 
Solved Threads: 6
jamello's Avatar
jamello jamello is offline Offline
Posting Whiz in Training

Re: Creating a VB dll

 
0
  #7
Apr 10th, 2007
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.

Originally Posted by Bejoyjohn View Post
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?
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 216
Reputation: jamello is an unknown quantity at this point 
Solved Threads: 6
jamello's Avatar
jamello jamello is offline Offline
Posting Whiz in Training

Re: Creating a VB dll

 
0
  #8
Apr 10th, 2007
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?

Originally Posted by mjwest10 View Post
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?
Last edited by jamello; Apr 10th, 2007 at 10:17 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 3
Reputation: bitbucket is an unknown quantity at this point 
Solved Threads: 0
bitbucket bitbucket is offline Offline
Newbie Poster

Re: Creating a VB dll

 
0
  #9
Apr 10th, 2007
Originally Posted by snostar View Post
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 2
Reputation: Bejoyjohn is an unknown quantity at this point 
Solved Threads: 0
Bejoyjohn Bejoyjohn is offline Offline
Newbie Poster

Re: Creating a VB dll

 
0
  #10
Apr 12th, 2007
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


Originally Posted by srikanthvja View Post
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC