Item Property Example

This example first displays the names of all open sessions, then displays the names of all visible QuickPads for the active session. It then goes on to show the difference between the explicit and implicit use of the Item method.

Sub Main()

 Dim Sys As Object, Sess As Object, QPad As Object

 

 Set Sys = CreateObject("EXTRA.System")

'Assumes at least one open session

 

 ' This tests the Item method for a Sessions object.

 NumberOfSessions = Sys.Sessions.Count

 For i = 1 to NumberOfSessions

  OpenSessions$ = OpenSessions$ + Sys.Sessions.Item(i).Name + " "

 Next

 MsgBox "The following sessions are open: " + OpenSessions$

 

 ' This tests the Item method for a QuickPads object. This
 ' example works equally well for toolbars. Substitute the
 ' QuickPads collection object with a Toolbars collection object.

 Set Sess = Sys.ActiveSession

 NumberOfQPads = Sess.QuickPads.Count

 For i = 1 to NumberOfQPads

  If Sess.QuickPads.Item(i).Visible Then

  VisiblePads$ = VisiblePads$ + Sess.QuickPads.Item(i).Name + " "

  End If

 Next

 MsgBox "The following QuickPads are visible: " + VisiblePads$

 

 ' There are two ways to make an item call, implicitly or
 ' explicitly, and two ways to index it, a numeric index
 ' and a string index. The above examples show an explicit
 ' call with a numeric index.

 

 ' This example shows an implicit call with a numeric index.

 For i = 1 To NumberOfQPads

  If Sess.QuickPads(i).Visible Then

  VisiblePads$ = VisiblePads$ + Sess.QuickPads(i).Name + " "

  End If

 Next

 MsgBox "The following QuickPads are visible: " + VisiblePads$

 

 ' This example shows an explicit call with a string index.

 If Sess.QuickPads.Item("Aid").Visible Then

  MsgBox "The Aid Quick Pad is visible."

 End If

 

 ' This example shows an implicit call with a string index.

 If Sess.QuickPads("Aid").Visible Then

  MsgBox "The Aid Quick Pad is visible."

 End If

End Sub