home *** CD-ROM | disk | FTP | other *** search
- Form1
- Dbase -III Sample
- Form15l
- List1
- List1
- List1
- Frame1
- Sort by:
- Option3
- P.O. Box
- Option2
- First name
- Option1
- Command4
- Delete
- Command3
- Command2
- << Prev.
- Command1
- Next>>
- Line2
- Line1
- datalabel3
- datalabel2
- datalabel1
- Label3
- P.O.Box:
- Label2
- First Name:
- Label1
- Name:
- about
- About
- separator
- endprogram
- Text1_Change
- Data1_Validate
- Actionm
- Data1_Reposition
- label4
- Caption
- recordcountf
- data1F
- @ Form_Load
- database
- table!
- RecordSource
- TableDefs
- Index&
- Connect
- DatabaseName
- MyTable[
- MyDB{
- databes*
- indexes
- fields
- Command1_Click
- Command2_Click
- text1
- datasource
- datafiled
- datafield
- text2
- text3l
- refresh_display
- Command3_Click
- Command4_Click
- delte;
- Option1_ClickL
- Option2_Click
- Option3_Click1
- about_ClickU
- PROGRAM
- PETER
- SCHULZE
- TY1PS
- endprogram_Click9
- table1
- treats
- directory
- containing
- tables
- dbase
- routine
- refreshes
- Form_Unload
- Cancel
- datalabel1
- datalabel2
- datalabel3
- moves
- record
- according
- current
- form1
- list1
- refresh_list
- MoveF
- newpat
- catcherrorz
- declare DATABASE as a databasevariable
- declare TABLE1 as table variable
- about_Click
- DBASE-III File and Index access with VB-3.
- Little demoprogram by Peter Schulze, TY1PS. 72253,2602@compuserve.com
- Dbase-III Sample
- Command1_Click
- this moves to the next record in the database according to the current index
- Command2_Click
- this moves to the previous record in the database according to the current index
- Command3_Click
- this adds a new record to the tablen
- all index files will be updated automatically
- First Name
- FIRST_NAME
- FIRST_NAME
- PO BOX
- POBOX
- POBOX
- Command4_Click
- this removes the current record from the database
- endprogram_Click
- END the programa
- Form_Load
- We first have to open the database.
- VB-3 treats the directory containing all database file as 'The Database'
- therefore the OpenDatabase command points to a disk directory
- make sure to have the DBF and NDX files in the c:\dbsample directory
- the two 'false', 'false' declarations assure that the file is openc
- in multiuser mode and for read and write operations
- C:\DBSAMPLE
- Dbase III;
- Please indicate the path where the BBS.DBF file can be found
- now VB knows where to find all information releated to the database. All DBF and NDX filese
- must be in the same directory.
- Next we select the data we want to work with. This is called a table.
- Each table is represented as a .DBF file. You can have as many tables as you like in
- a database (=disk directory).
- Each table is kept in a seperate .DBF file.
- in this example we access a Table called BBS.DBFf
- A table contains the actual data as well as the field structures.
- You can create new tables using VB commands but it is much easier
- to use the Datamgr.Exe program that comes with VB for this purpose.
- To create a new table (DBF) file with datamgr select 'Open Database' from the 'FILE' menu.e
- Yes this is a bit strange, the 'new database' menu will not allow for the
- creation of new tables in dbase format, but' 'Open Database' does
- now select 'DBASE-III' and then choose the directory where you want to create the files.
- The 'new table' button now creates new DBF files, whereas you can add .NDX index files with the
- 'ADD/DELETE INDEXES' options. More about indexs later.e
- now we have opened the BBS.DBF datafile and it is ready for use
- in order to speed up searches in a database, we have to use what is called Indexes.
- a index is nothing else but sort key for your data.
- This allows us to quickly change the sort order and search for records withoute
- the need to call a lenghtly sort routine.
- Dbase uses .NDX files to keep indexes. Each index has its own .NDX file.i
- You can have as many NDX files as you wish, but you should keep them to the minimum neededh
- as otherwise keeping track of all the .NDX files will slow your program down. n
- in this sample i have declared 3 Indexes:
- NAME (NAME.NDX) contains the data sorted by name
- FIRSTNAM (FIRSTNAM.NDX) sorts by the first name
- POBOX (POBOX.NDX) sorts by the boxnumbers
- with these 3 indexes avaiable i can easily change the order of my records by changing
- the index used, without the need to re-sort all data.
- at startup i select 'name' as index. this means the data will be sorted by name.n
- indexing is also essential to quickly find data in the database.
- with indexes i can use the very quick 'SEEK' command.
- without indexes i woul have to use 'Findfirst' which is a lot slower.
- now i want to have something on the screen at program start, so i call the
- routine that refreshes
- my screen
- this ends the initialisation
- Form_Unload
- before ending i have to close my tables and databasem
- this assures that all is written to disk and no data lost
- Option1_Click
- i want the data to be sorted by name.
- setting the index to "NAME" does the job
- Option2_Click
- i want the data to be sorted by First name.
- setting the index to "FIRSTNAM" does the jobb
- FIRSTNAM
- Option3_Click
- i want the data to be sorted by PO-BOX number
- setting the index to "POBOX" does the job
- POBOX
- refresh_display
- this updates my screen P
- FIRST_NAME
- POBOX
- refresh_list
- this updates the list boxes
- FIRST_NAME
- POBOX
-