Have a car at the moment, for example, a type of car, license plate, production date... Attribute
I declared in the module structure types, and defines the global structure variable
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Private type tCar
CarType as string
CarID as string
End type
Public Car as tCar
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
There is no question of above,
In other forms call no problem
Such as: Car type="mercedes-benz"
================================
But now I don't want to do with the module, I think he is defined as a class
I add a blank class and named cls_Car
In the class wrote
Private type tCar
CarType as string
CarID as string
End type
Public Car as tCar 'began to complain here
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Compile all compiled not the past, he suggests the public global declarations can't use a custom type · · · · · · ·
Why is this? Please explain to me why, as carefully as possible, I want to learn,
==========================================
Here's what I try to use other methods
In the class wrote
Public CarType as string
Public CarID as string
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
In other forms, the
Dim the Car as New cls_Car
Car. Cartype="mercedes-benz"
It is possible, as I understand the class,
========================================
There is a problem believe that class above declared in the global structure of the problem is resolved
This sure is settled, they two error as the nature of the
If at the moment the people sitting on the bus, so name, gender... is he wants some attribute
I wrote in the cls_Car
Private type tPerson
The Name as string
Sex as a Boolean
End type
Private type tCar
CarType as string
CarID as string
The number of the Person (s) as tPerson 'uncertain, so the definition of dynamic array
End type
Public Car as tCar
'want to achieve the purpose of the above is my final, but did not compile the past
=================================
CodePudding user response:
My solution is: change the type to the class and type members into a class member.CodePudding user response: