Click to See Complete Forum and Search --> : Help: Life of Controls in DataSpaces


simi
February 14th, 2000, 09:22 PM
If I create a class in a dataspace with a private variable called Count then every time I run a function in this class the private variable is set to zero.
This is provided I create the object via a DataSpace

ie X.Y
Private Count as Long

Public Function Add(Num as Long) as Long
Count = Count + Num
Add = Count
end function

---

If I use the dataspace.createobject to a global object, then every time I call Add(Num) the value returned by Add is Num not the totaled amount.

Any ideas how to make this object stay persistent?

Thanks

DS

Kyle Burns
February 16th, 2000, 07:56 AM
Use a static variable in your function.

public Function Add(Num as Long) as Long
static Count as Long
Count = Count + Num
Add = Count
End Function