How to write Inheritance Program in Vb.Net using New Keyword.
Develop Logic by writing Code.
Public Class Class1
Public a, p As Double
Public Sub area(ByVal ra As Integer)
a = 3.14 * ra * ra
p = 2 * 3.14 * ra
End Sub
End Class
Public Class Class2
Inherits Class1
Dim w As New Class1
Dim r As Double
Public Sub accept()
'Console.WriteLine("enter the radius")
'r = Console.ReadLine
'w.area(r)
Console.WriteLine("area=" & a)
Console.WriteLine("perimeter=" & p)
End Sub
End Class
Module Module1
Sub Main()
Dim a As Integer
Console.WriteLine("enter the redius")
a = Console.ReadLine()
Dim d As New Class2
d.area(a)
d.accept()
Console.ReadLine()
End Sub
End Module
Develop Logic by writing Code.
Public Class Class1
Public a, p As Double
Public Sub area(ByVal ra As Integer)
a = 3.14 * ra * ra
p = 2 * 3.14 * ra
End Sub
End Class
Public Class Class2
Inherits Class1
Dim w As New Class1
Dim r As Double
Public Sub accept()
'Console.WriteLine("enter the radius")
'r = Console.ReadLine
'w.area(r)
Console.WriteLine("area=" & a)
Console.WriteLine("perimeter=" & p)
End Sub
End Class
Module Module1
Sub Main()
Dim a As Integer
Console.WriteLine("enter the redius")
a = Console.ReadLine()
Dim d As New Class2
d.area(a)
d.accept()
Console.ReadLine()
End Sub
End Module
0 comments: