Create A new Project
Code:
- Public Class MainClass
- Class subClass1
- Shared Sub ShowMsgBox(ByVal title As String, ByVal text As String)
- MsgBox(text, MsgBoxStyle.Information, title)
- End Sub
- Shared Function GetAverage(ByVal number1 As Integer, ByVal number2 As Integer)
- Return ((number1 + number2) / 2)
- End Function
- End Class
- Sub AnotherNonSard()
- 'Dose somethink private hare.....
- End Sub
- 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
- Imports MyDLL.MainClass
- Public Class Form1
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- ' does not exist yet, Because we have to emport it into our project...
- subClass1.ShowMsgBox(TextBox1.Text, TextBox2.Text)
- Me.Text = subClass1.GetAverage(10, 4)
- End Sub
- End Class
Result: