A Demonstration Application
This application provides a simple demonstration of the ease with which the Visual Basic Ecco Toolkit allows a developer to write programs to perform sophisticated data management within Ecco.
| ATTENTION C++ PROGRAMMERS: Sample code in C++ has been provided by Kerry Zimmerman and is available from our web site. Press here to download. |
BIRTHDAY.EXE pops up a dialog box containing a drop-down list of the months of the year. Select any month of the year, press the OK button, and BIRTHDAY.EXE will extract all persons listed in the Ecco file who have a birthday occurring during that month, and place those persons in a list box sorted by birthday.
BIRTHDAY.EXE was literally written and debugged in less than 20 minutes, user interface and all. The demo archive includes the source code for BIRTHDAY.FRM. This source code will show how simple it is to control Ecco and to extract data from Ecco files using the VB Ecco Objects collection. The source code will also illustrate some of the specifics of coding which are documented in this reference.
'Insert in Global
Dim MyEcco As EccoApp
Dim MyFolder As EccoFolder
Dim MyItem As EccoItem
Dim MySelection As EccoItems
Private Sub Form_Load()
'Initialize
Set MyEcco = New EccoApp
'Substitute your own developer id for the code below
'This application will run prior to January 1, 2002
MyEcco.Register "xxxxxxxx", , , #1/1/2002#
'Link to an Ecco folder called "Birthday"
Set MyFolder = New EccoFolder
MyFolder.Name = "Birthday"
If MyFolder.ID = 0 Then 'Birthday folder wasn't found
z = MsgBox("This Ecco file doesn't have a birthday folder!", vbInformation)
End
End If
'Center the form on the screen
BirthdayForm.Top = Screen.Height / 2 - BirthdayForm.Height / 2
BirthdayForm.Left = Screen.Width / 2 - BirthdayForm.Width / 2
With MonthCombo 'Initialize the dropdown list of months
.Clear
.AddItem "January"
.AddItem "February"
.AddItem "March"
.AddItem "April"
.AddItem "May"
.AddItem "June"
.AddItem "July"
.AddItem "August"
.AddItem "September"
.AddItem "October"
.AddItem "November"
.AddItem "December"
.ListIndex = 0
End With
'Clear the output list box
BirthdayList.Clear
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set MyEcco = Nothing
Set MyFolder = Nothing
Set MySelection = Nothing
Set MyItem = Nothing
End
End Sub
Private Sub OKButton_Click()
BirthdayList.Clear
sfindstring = "Birthday = " + MonthCombo.Text
Set MySelection = MyFolder.Items
Set MySelection = MySelection.Find(sfindstring)
If MySelection.Count = 0 Then 'No birthdays this month
BirthdayList.AddItem "No birthdays found!"
Else 'Add each birthday to the list
sBirthdays = ""
For Each MyItem In MySelection
BirthdayList.AddItem Format$(MyItem.FolderValue("Birthday"), "mmm. d") + Chr$(9) + MyItem.FullName
Next
MsgBox "Finished!"
End If
End Sub