How to create class in VB.NET

2 Answers

0 votes
Class Test
    Private n As Integer

    Public Sub New()
        n = 3
    End Sub

    Public Function Calc() As Integer
        Return n * 10
    End Function
End Class

Module Module1

    Sub Main()

        Dim o As Test = New Test()
        Console.WriteLine(o.Calc())

    End Sub

End Module

' run:
' 
' 30

 



answered Sep 17, 2018 by avibootz
0 votes
Class Test
    Private _robo As String

    Public Sub New(ByVal robo As String)
        _robo = robo

        Console.WriteLine(_robo)
    End Sub

    Public Sub Show()
        Console.WriteLine(_robo)
    End Sub
End Class


Module Module1

    Sub Main()

        Dim o As Test = New Test("R2D2")

        o.Show()

    End Sub

End Module

' run:
' 
' R2D2
' R2D2

 



answered Sep 17, 2018 by avibootz
...