[Gambas-user] Not an Object (Collection)
tobs at taboege.de
Sun Jun 20 00:04:28 CEST 2021
On Sat, 19 Jun 2021, John Dovey wrote:
> I define a collection and later add a value to it:
> Dim WorkCmd As New Collection ' Leaving out the "new" makes no difference
> WorkCmd.Add(Date(Now), "BoneDate")
> When I try to check for an existing key, it tells me it's "Not an Object"
> Print "Date: ", WorkCmd["BoneDate"] ' <-- This works
> Print WorkCmd["BoneDate"] '<-- This works
> Print WorkCmd["BoneDate"].Exist '<-- This doesn't
> If Print WorkCmd["BoneDate"].exist then '<-- This gives the same error
You're retrieving the value at "BoneDate" and call the Exist method
on that value. Given that you stored a Date value in there, which is
not an object, the error is justified. A Date value has no "Exist"
I think you want WorkCmd.Exist("BoneDate").
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User