Typically, structures are best suited for modeling geometric and mathematical data and
are created in VB using the Structure keyword.
' A VB structure type.
Structure Point
' Structures can contain fields.
Public xPos As Integer, yPos As Integer
' Structures can contain parameterized constructors.
Public Sub New(x As Integer, y As Integer)
xPos = x
yPos = y
End Sub
' Structures may define methods.
Public Sub PrintPosition()
Console.WriteLine("({0}, {1})", xPos, yPos)
End Sub
End Structure
Comments
Post a Comment