by Chrysovalantis Anastasiades (5 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 6th October 2008
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Simple way to start learning classes
API Declarations
'////
Public a As Double
Public area As Double
Public volume As Double
Private Sub Class_Initialize()
a = 0
area = 0
volume = 0
End Sub
Public Sub Calculate()
area = a * a
volume = area * a
End Sub
'and add one command button
'////
Dim cube1 As New Cube
Private Sub Command1_Click()
cube1.a = InputBox("Insert the side length ", "")
cube1.Calculate
Print "The area of a square with a side = " & cube1.a & vbCrLf & " is equal to " & cube1.area
Print vbCrLf
Print "The volume of a cube with a side = " & cube1.a & vbCrLf & " is equal to " & cube1.volume
End Sub