Android Question B4A - Getting data in and out of Objects

Brian Dean

Well-Known Member
Licensed User
Longtime User
This is not a problem - just a question in case I have overlooked something.

What is a good way to move related data values (essentially records) in and out of Objects? The obvious way is to declare a type, but a type cannot be declared within an object (no global subs in class modules). This means that any project using the object has to declare the type inside its own Process_Globals, which is not a big problem but seems untidy as the type really belongs (as a data structure definition) to the object.

For instance, if I had an object called "geometry" I might want to use ...

type shapeInfo (points as int, area as float, perimeter as float)
....
....
Dim s as shapeInfo
s = geometry.getShapeInfo(vertices() as int)

... and in the class module ...

Public Sub getShapeInfo(vertices() as int) as shapeInfo
.....

Am I missing some obvious solution?
 

JordiCP

Expert
Licensed User
Longtime User
but a type cannot be declared within an object (no global subs in class modules)
Unless I understood it wrong, what you are asking for is possible. A type can be declared in a class module, and the class Subs can return objects of this type, which will be correctly 'seen' from other modules (unless this type is declared as private inside the class).
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Unless I understood it wrong, what you are asking for is possible. A type can be declared in a class module, and the class Subs can return objects of this type, which will be correctly 'seen' from other modules (unless this type is declared as private inside the class).

You are right, of course. Somehow I had lost my "Class_Globals" sub - a "type" will go in there very well.

Thanks for your help.
 
Upvote 0
Top