Hi......
DLL statds for Dynamic Link Library which comprise Business logic .At A huge level of
Software development it is suitable to implement business login separately.
DLL provides facility of reversibility means ones you have been created a DLL
for a task then many project can use your DLL, Like if you have a DLL of
Calculator logic then many Application can use it after importing DLL ij their project...
DLL in VB 6.0
- Open VB 6.0 and select ActiveXdll
- Change your final project name as you're going to make otherwise you may be face problem of name contradiction because default name of dll project is Project 1 and VB Standard exe has also same so change name of dll project or standard exe project
- On Project explorer window change of class1 as your requirement
- now make some procedure and function of your logic as showing in following picture
- Save DLL project
- For make DLL select File > Make Project1 DLL...
- Now your DLL is ready to use
- Open VB 6.0
- Select Standard EXE
- For add a DLL in your project ..
- Go to Project > Refereneces.
- Browse Your DLL File and click open
- Now you can use DLL class
- Make an object of class which you have made in your DLL project
- Call function of your DLL class using . operator
Private Sub Command1_Click()
Dim ob As New Class1
ob.Show
End Sub
Private Sub Command2_Click()
Dim ob As New Class1
MsgBox (ob.Sum(10, 20))
End Sub
DLL in C# and VB.Net
- Open Visual studio 2008 File > Project > Select class library form template
- Implement your function and logic inside class body
- After implementing logic press f6 for build your DLL Project
- For use a DLL in windows Application right click of root folder from solution explorer
- Add References..
- Browse your project DLL
- Now make an object of class which you have named in DLL file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClassLibrary1
{
public class Class1
{
public int sum(int a,int b)
{
return a + b;
}
}
}
Code of window Application file where DLL has been used
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ClassLibrary1.Class1 ob = new ClassLibrary1.Class1();
MessageBox.Show(ob.sum(10,20).ToString());
}
}
}
No comments:
Post a Comment