VB.net Program to Return an Object of the Class From the User-Defined Function

You are currently viewing VB.net Program to Return an Object of the Class From the User-Defined Function

VB.Net program to return an object of the class from the user-defined function

'VB.Net program to return an object of the class 
'from a user defined function.

Module Module1
    Class Cls
        Public num1 As Integer
        Public num2 As Integer
    End Class


    Function GetObject() As Cls
        Dim M As New Cls

        M.num1 = 10
        M.num2 = 20

        Return M
    End Function

    Sub Main()
        Dim str As New Cls

        str = GetObject()

        Console.WriteLine("Member of class are:")
        Console.WriteLine("Num1: {0}", str.num1)
        Console.WriteLine("Num2: {0}", str.num2)
    End Sub

End Module
Member of class are:
Num1: 10
Num2: 20
Press any key to continue . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply