Public Class Class1
Public su As Integer
Public Sub hello()
MsgBox("ashish wellcomes you")
End Sub
Public Sub sum(ByVal x1 As Integer, ByVal x2 As Integer)
su = x1 + x2
MsgBox("sum is =" & su)
End Sub
Public Overloads Function sum(ByVal x3 As Integer, ByVal x4 As Integer) As Integer
su = x3 + x4
Return su
End Function
Public Overloads Function sum(ByVal a1 As Integer, ByVal a2 As Integer, ByVal a3 As Integer) As Integer
su = a1 + a2 + a3
Return su
End Function
End Class
Public Class Class2
Public final As Integer
Public Property addition(ByVal a1 As Integer, ByVal a2 As Integer) As Integer
Get
final = a1 + a2
Return final
End Get
Set(ByVal value As Integer)
final = value
End Set
End Property
Public Overridable Function ov_add(ByVal j1 As Integer, ByVal j2 As Integer) As Integer
final = j1 + j2
Return final
End Function
Public Function ov_mul(ByVal j1 As Integer, ByVal j2 As Integer) As Integer
final = j1 * j2
Return final
End Function
End Class
Public Class Form1
Dim a As New Class1
Dim suj As Integer
Dim psuj As Integer
Dim b As New Class2
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
a.hello()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
suj = a.sum(CInt(TextBox1.Text), CInt(TextBox2.Text))
MsgBox("the result is = " & suj)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'psuj = b.addition(2, 3)
psuj = b.addition(CInt(TextBox1.Text), CInt(TextBox2.Text))
MsgBox("" & psuj)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
suj = a.sum(2, 3, 4)
MsgBox("overload output = " & suj)
End Sub
End Class
Public Class Form2
Dim fr As Class2
Dim fr1 As Class3
Dim a As Integer
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'a = fr.ov_add(CInt(TextBox1.Text), CInt(TextBox2.Text))
a = fr.ov_mul(2, 2)
MsgBox("class2 = " & a)
End Sub
End Class
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||