DotNetWebTutor.com                                                    Link to Us

Deploying An Application with a Dynamic Link Library
deploy dll

  • Create a new project
    • Select Visual Basic
    • Class Library
    • Name it
    • Make sure its added to your solution
    • Click OK

add new item class library
It adds the files into your solution
class1.vb

  • rename the class
  • Add code into the class to add your two numbers

Private _num1 As Integer
Private _num2 As Integer
Public Property num1() As Integer
Get
Return _num1
End Get
Set(ByVal value As Integer)
_num1 = value
End Set
End Property
Public Property num2() As Integer
Get
Return _num2
End Get
Set(ByVal value As Integer)
_num2 = value
End Set
End Property
Public Function Add(ByVal n1 As Integer, ByVal n2 As Integer) As Integer
Return n1 + n2
End Function

  • Right click on the class project and select Build

build

 

add reference
add reference from projects

  • Open your windows project
  • Add this code globally

Dim myAdd As New AddNumbers.Addnumbers()

You must use the AddNumbers namespace because that is the project it is in

  • Now add code in the button_click to use the class to add the numbers

myAdd.num1 = CType(txtNum1.Text, Integer)
myAdd.num2 = CType(txtNum2.Text, Integer)
lblResult.Text = myAdd.Add(myAdd.num1, myAdd.num2)

  • Test it
deploy dynamic link library