![]() ![]() ![]() ![]() Gravitybox Schedule Primer
Page 20
1998-2004 Gravitybox Software LLC
value. If the value does not map to any valid value in the Rooms collection, nothing will
happen. The only error that may happen is one of logic. If you set this property to
Room1 and the name of the room you wish to map is Room 1, the appointment will
not be displayed in the proper room. This may cause puzzling results, if you make this
error, but no run-time error will be raised.
A room may be added to the Rooms collection with the Add method in the following
fashion.
Call Schedule1.Rooms.Add(Room1)
The new room will be named Room1. This object may be referenced by name or index
[1..N]. The following code fragments are equivalent.
Debug.Print Schedule1.Rooms(Room1).Name
Debug.Print Schedule1.Rooms(1).Name
A Room objects name may not be numeric. This is because there would be no way to
determine if the parameter being used is a name or an index. Since you may not add a
numeric name the code below is invalid but I use it as an illustration. If an objects name
were numeric, the following code would produce an error, since there is only one object
in the collection and its name is 100. When referenced by the name 100, the
collection will try to return index 100, which does not exist, and produce an error.
Call Schedule1.Rooms.Add(100)
Debug.Print Schedule1.Rooms(100).Name ERROR
This logic also applies to all object collections in this product. The name of no object
may be numeric.
Rooms may not be renamed directly. By this I mean that the following code will
not execute. It will not rename the first Room object in the collection to NewName.
Schedule1.Rooms(1).Name = NewName
This code will produce an error, because the Name property is read-only. If the name of
existing Room needs to be changed, the collections Rename method must be used. If,
as in the previous example, the first Room object is to be renamed NewName, the
following code would work.
Call Schedule1.Rooms.Rename(1, NewName)
The Rooms collection actually has many useful methods. These may be used to
manipulate Room objects within the collection. There are also search functions that
make finding a particular object much easier. Additional language support for the
displayed schedule may be provided as well, with the collections DisplayName
|