Creating And Using Custom DLL For beginners

 Create A new Project
 
 
 
 
 
 
 
Code: 
  1. Public Class MainClass  
  2. Class subClass1  
  3. Shared Sub ShowMsgBox(ByVal title As String, ByVal text As String)  
  4. MsgBox(text, MsgBoxStyle.Information, title)  
  5. End Sub  
  6. Shared Function GetAverage(ByVal number1 As Integer, ByVal number2 As Integer)  
  7. Return ((number1 + number2) / 2)  
  8. End Function  
  9. End Class  
  10. Sub AnotherNonSard()  
  11. 'Dose somethink private hare.....  
  12. End Sub  
  13. End Class 
Note:

Insert and sub , functions etc.in hare, but declare as 'Sared' they can be 'accessed by External project.
 
Next Build This project...
 
Build> MyDELL

 
 
 ........... Close First project....
 
 
 Create another new project.....
 
**You need 2 textbox and 1 button.
 
 
 
 *** Code Source.
 
 
 Now Add Reference : From First Project
 
 
 
 Next:
 
 
 
 
 
 Code:
 
Button Click Event
  1. Imports MyDLL.MainClass  
  2. Public Class Form1  
  3. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  
  4. ' does not exist yet, Because we have to emport it into our project...  
  5. subClass1.ShowMsgBox(TextBox1.Text, TextBox2.Text)  
  6. Me.Text = subClass1.GetAverage(10, 4)  
  7. End Sub  
  8. End Class 
 
 Result:
 
 
 
 
 
 
 
X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now