例: Sub Delete

' Define the class Customer.
Class Customer
   Public Name As String
   Public Address As String
   Public Balance As Currency

   ' Define a constructor sub for the class.
   Sub New (Na As String, Addr As String, Bal As Currency)
      Me.Name$ = Na$
      Me.Address$ = Addr$
      Me.Balance@ = Bal@
   End Sub
 
   ' Define a destructor sub for the class.
   Sub Delete
      Print "Deleting customer record for: "; Me.Name$
   End Sub
End Class

' Create an object of the Customer class.
Dim X As New Customer("Acme Corporation", _
   "55 Smith Avenue, Cambridge, MA", 14.92) 
Print X.Balance@
' Output:
' 14.92

' Delete the object, first running the destructor sub.
Delete X
' Output:
' Deleting customer record for: Acme Corporation."

' Then the object is deleted.