Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How to Make DLL Using Visual Basic.Net (Part3)

Author: DevASP
Download Source Code : 345_UseMyDLL.zip

This is a Advance topic but if beginner study this they can do this easily. In this simple article you will learn to use DLL (Dynamic Link Library) using VB.Net.

Follow these steps to  ADD new DLL

 

First create a new project and now

Select DLL file and place it in the project folder which you make before.

Project à Add References

 

Now there opens a window it has three tabs select third tab named projects. Now browse DLL file MyDLL which you place before and press OK. Your DLL is added in references of project. Now you can use it easily.

 

Now drag two numeric up down, four buttons and a textbox on the form1.

 

Numeric Up Down 1 having name txt1.

Numeric Up Down  2 having name txt2.

Textbox 1 with name txtresult

 

Now write code on form1 load event

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

        TXT1.Value = 5

        TXT2.Value = 10

        TXTRESULT.Text = 0

 

End Sub

Now write code against buttons

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        Dim a As New MyDLL.Class1

        TXTRESULT.Text = a.ADD(TXT1.Text, TXT2.Text)

 

End Sub

 

 

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

 

        Dim a As New MyDLL.Class1

        TXTRESULT.Text = a.Subtraction(TXT1.Text, TXT2.Text)

 

End Sub

 

 

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

 

        Dim a As New MyDLL.Class1

        TXTRESULT.Text = a.Multiplication(TXT1.Text, TXT2.Text)

 

End Sub

 

 

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

 

        Dim a As New MyDLL.Class1

        TXTRESULT.Text = a.Division(TXT1.Text, TXT2.Text)

 

End Sub

Now you can make this form using your DLL and nobody can see its code.

Article Comments
the DLL file is very important for me.so that i would like to know more about it.

Posted on 8/1/2007 12:39:30 AM by noimok

this is excellent example for a beginner, i get lots of help from it and seems o problem to me. thanks a lot.

Posted on 12/8/2009 1:30:07 AM by Irfan

Thanks for this example. Very helpful to create First DLL by my own. I have seen some programs, in which they dont add the DLL as reference. They declared the DLL location and function.

Public Declare Function ADD Lib "C:\VbNet\MyDLL.dll" (ByVal one As Integer, ByVal two As Integer)

and inside the Button4_Click I wrote,

Label3.Text = ADD(TextBox1.Text, TextBox2.Text)

This is not working. Can you suggest me how to do it without adding the DLL to reference. Thanks



Posted on 12/8/2009 1:35:34 AM by udhay

Hi udhay,

Normally we call system DLLs function with this here is an example it will help you

Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long

Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim Length As Long
Dim sName As String
Dim Temp As String
Static iCount As Integer

iCount = iCount + 1
Length = GetWindowTextLength(hwnd) + 1

If Length > 1 Then
sName = Space(Length)
GetWindowText hwnd, sName, Length
If Left(sName, Length - 1) Like "Order*" Then MsgBox "window found!"
End If

EnumWindowsProc = 1
End Function


Thanks.

Posted on 12/8/2009 4:06:25 AM by zunnair

Neat and easy to follow. Thanks for the tutorial! Now I have an idea how to create and use a dll

Posted on 1/27/2010 3:48:52 AM by Nier

hi..
actually i know little bit abt the private dll and how to creae.. but i dnt know anything how to create a 64bit private dll in .net

Posted on 4/1/2010 9:14:50 AM by vipin

Hi!
I Lockup All of Internet & MSDN but Can't found any Good article about DLL's. Your Article Is Great! and help me to create Hidden-code library!

Posted on 11/1/2010 5:53:31 PM by BehnamZaki

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How to Make DLL Using Visual Basic.Net (Part 2)

Disclaimer - Privacy
© 2002-2017 DevASP.net