[Gambas-user] Collection initialize
Stephen Bungay
sbungay at ...981...
Mon Nov 17 20:45:33 CET 2008
Collections don't work that way.
What you do is create a class for the field items, add the values to
the class, then add the instance of the class to the collection.
' Gambas Class File
' This class is going to be added to a collection
Public Field1 AS String
Public Field2 AS String
Public Field3 AS String
Public Field4 AS String
'Gambas Class File
' This is another class file... perhaps your form..
' ClassMyRecord is a gambas class that has the record structure in it.
DIM MyRecord AS ClassMyRecord
DIM X AS Integer
X = 1 ' This is the index into the collection.
' if iterating through a recordset and adding it
' to a collection a FOR loop would be used. For this
' one-off example I'm setting it to 1, just so it works.
MyRecord = NEW ClassMyRecord
WITH MyRecord
.Field1 = "This"
.Field2 = "is"
.Field3 = "a"
.Field4 = "test."
END WITH
MyClass.add(MyRecord,X)
MyRecord = NULL
Stefan Miefert wrote:
> Hello,
>
> how can i do something like this
>
> Public mycollection as new collection = [field1 = "test",field2="test2"]
>
>
> ?
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list