|
|
|
|
|
|
|
|
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.
|
|
|
back to top |
|
|