by Chrysovalantis Anastasiades (5 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 7th November 2008
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Simple way to make equal two 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
'///////////////////////////////////////////////////////////////////'
Public Sub equality(cub As cube)
cub.a = a
cub.area = area
cub.volume = volume
End Sub
'and add one command button
'////
Dim cube1 As New cube
Dim cube2 As New cube
Private Sub Command1_Click()
cube1.a = InputBox("Insert the side length ", "")
cube1.Calculate
Print "Cube1" & vbCrLf
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
Print vbCrLf
cube1.equality cube2
cube2.Calculate
Print "Cube2" & vbCrLf
Print "The area of a square with a side = " & cube2.a & vbCrLf & " is equal to " & cube2.area
Print vbCrLf
Print "The volume of a cube with a side = " & cube2.a & vbCrLf & " is equal to " & cube2.volume
End Sub