VintageObjectsSet
VintageObjectsSet Properties
Count
int Count { get; }
Description: Returns a Long containing the number of objects (>=0) in the VintageObjectsSet collection.
Example:
Dim VObjsSet As VintageObjectsSet
...
IF (VObjsSet.Count > 0) Then
'we do something
...
End If
Item
object this[int Index] { get; }
Description: The default property. Given a numeric index, returns a reference to the corresponding member of the VintageObjectsSet collection. The index can be a number from 1 to the value of the Count property. If the Index value doesn't match any existing member of the collection, the following error occurs: "Runtime error 5: Invalid procedure call or argument"
Example:
Dim vobjs As VintageObjects
Dim VObjsSet As VintageObjectsSet
...
Set VObjsSet = New VintageObjectsSet
...
Set vobjs = VApp.GetLocalObjects("VY_PROJECT")
VObjsSet.Add vobjs
Set vobjs = VApp.GetLocalObjects("VY_RESOURCE")
VObjsSet.Add vobjs
...
MsgBox VObjsSet(2)(5).ObjectName ' prints the name of the 5th resource
VintageObjectsSet Methods
Add
void Add(ref object Objects)
Description: Adds a new object of the VintageObjects type to the end of the VintageObjectsSet collection.
Raised errors:
Err.Number | Err.Description |
-209 | "Line number is out of range" |
-210 | "Invalid parameter" |
Example:
Dim vobjs As VintageObjects
Dim VObjsSet As VintageObjectsSet
...
Set vobjs = VApp.GetLocalObjects("VY_PROJECT")
VObjsSet.Add vobjs
GetEnumerator
System.Collections.IEnumerator GetEnumerator()
Description: Makes VintageObjectsSet an enumerable collection and allows using the foreach method.
Example: see GetEnumerator() for VintageObjects
Remove
void Remove(int LineNumber)
Description: Removes an object of the VintageObjects type from the ItemNumber place of the VintageObjectsSet object. The Count property is decreased by 1.
Raised errors:
Err.Number | Err.Description |
-209 | "Line number is out of range" |
-210 | "Invalid parameter" |
Example:
Set vobjs = VApp.GetLocalObjects("VY_PROJECT")
VObjsSet.Add vobjs
Set vobjs = VApp.GetLocalObjects("VY_RESOURCE")
VObjsSet.Add vobjs
MsgBox CStr(VObjsSet.Count) ' prints 2
VObjsSet.Remove 1
'the first vobjs collection has been removed and the second one has moved
' to the first place
MsgBox CStr(VObjsSet.Count) ' prints 1
VintageObjectsSet Events
VintageObjectsSet has the same events as VintageObjects with only an additional parameter specifying the item of the set.
AddObject
void AddObject(int ObjectsNumber, int LineNumber)
Description: The event is triggered when a VintageObject object has been added to a VintageObjects collection included into the VintageObjectsSet.
The VObjsNumber parameter tells the position of the parent Vobjs collection inside the VintageObjectsSet.
The LineNumber parameter tells the position of the object that was added, changed or deleted.
Note that numbering of the objects in the sets starts from 1.
Example:
Private Sub VSet_AddObject(ByVal ObjectsNumber As Long, ByVal lineNumber As Long)
Dim voNew As VintageObject
'Do something (update the list)
Set voNew = VSet(ObjectsNumber)(lineNumber)
List1.AddItem voNew.ObjectName
End Sub
DeletingObject
void DeletingObject(int ObjectsNumber, int LineNumber)
Description: The event is triggered when a VintageObject object is to be removed from a VintageObjects collection included into the VintageObjectsSet.
Example:
Private Sub VSet_DeletingObject(ByVal ObjectsNumber As Long, ByVal lineNumber As Long)
MsgBox "You are deleting " + VSet(ObjectsNumber)(lineNumber).ObjectName
End Sub
ObjectChanged
void ObjectChanged(int ObjectsNumber, int LineNumber)
Description: The event is triggered when a VintageObject object has been changed in a VintageObjects collection included into the VintageObjectsSet.
Example:
Dim VApp As Vintage
Dim WithEvents VSet As VintageObjectsSet
...
Private Sub Form_Load()
Dim Vobj As VintageObject
Set VApp = New Vintage
Set VSet = New VintageObjectsSet
VSet.Add VApp.GetLocalObjects("VY_Person")
VSet.Add VApp.GetLocalObjects("VY_Company")
Set Vobj = VSet(1)(1)
Vobj.Value("email") = Vobj.Value("FirstName")+ "." +Vobj.Value("LastName") +"@acme.com"
Vobj.SaveChanges 'This will raise vset_ObjectChanged
End Sub
Private Sub VSet_ObjectChanged(ByVal ObjectsNumber As Long, ByVal lineNumber As Long)
Dim voChanged As VintageObject
Set voChanged = VSet(ObjectsNumber)(lineNumber)
...
End Sub
ObjectDeleted
void ObjectDeleted(int ObjectsNumber, int LineNumber)
Description: The event is triggered when a VintageObject object has been removed from a VintageObjects collection included into the VintageObjectsSet.
Comments
0 comments
Please sign in to leave a comment.