VB.NET tutorial-Class Methods

Object-Oriented Programming (OOP)

Class Methods

Method is a member of a class that can be called to perform a specific task. You can call the method when you create the object of the class. You can read this page VB.NET_OOP_Create_Objects.htm to learn how to call the method. A method can accept parameters so that values can be passed to the method. You can write parameters for method as you did with the sub-procedure and function. If you don't know how to write parameters for a sub-procedure or function, please read this page VB.NET_Sub-Procedure_Function_Parameters.htm


Module Module1
    Sub Main()
    End Sub
    Class Student

        Private stnumber As Integer
        Private stname As String
        Private stsex As String

        Public Sub setnumber()
            Console.WriteLine("Enter student's number:")
            stnumber = CInt(Console.ReadLine)
        End Sub
        Public Sub printnumber()
            Console.WriteLine("Student's number is:" & stnumber)
        End Sub
    End Class
End Module

This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.