Examples: Class statement

' Define a class.
Class textObject
   ' Declare member variables.
   backGroundColor As Integer
   textColor As Integer
   contentString As String
   ' Define constructor sub.
   Sub New (bColor As Integer, tColor As Integer, _
      cString As String)
      backGroundColor% = bColor%
      textColor% = tColor%
      contentString$ = cString$
   End Sub
   ' Define destructor sub.
   Sub Delete
      Print "Deleting text object."
   End Sub
   ' Define a sub to invert background and text colors.
   Sub InvertColors
      Dim x As Integer, y As Integer
      x% = backGroundColor%
      y% = textColor%
      Me.backGroundColor% = y%
      Me.textColor% = x%
   End Sub
End Class

' Create a new object of class textObject.
Dim y As textObject
Set y = New textObject(0, 255, "This is my text")
' Invert the object's background and text colors.
y.InvertColors
' Delete the object.
Delete y
' Output:
' Deleting text object.