Monday 20 August 2012

Interface in vb.net | imath

How to implements Interface in Vb.Net
Public Interface imath
    Function add(ByVal a As Integer, ByVal b As Integer) As Integer
    Function subst(ByVal a As Integer, ByVal b As Integer) As Integer
End Interface
Public Class math
    Implements imath
    Public Function add(ByVal a As Integer, ByVal b As Integer) As Integer Implements imath.add
        Return a + b
    End Function
    Public Function subst(ByVal a As Integer, ByVal b As Integer) As Integer Implements imath.subst
        Return a - b
    End Function
End Class
 save page as math.vb


code for interface


Module Module1

    Sub Main()
        Dim s As New math
        Dim d, w As Integer
        ''Dim obj As New math
        Console.WriteLine("enter the value of d & w")
        d = Console.ReadLine()
        w = Console.ReadLine()
        'Console.WriteLine(obj.add(a, b))
        'Console.WriteLine(obj.subst(a, b))
        'Console.ReadLine()
        Console.WriteLine(s.add(d, w))
        Console.WriteLine(s.subst(d, w))
        Console.ReadLine()
    End Sub

End Module

Save as Module1.vb
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: