home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / database / dbase / dbsample.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-11-09  |  8.1 KB  |  194 lines

  1. Form1
  2. Dbase -III Sample
  3. Form15l
  4. List1
  5. List1
  6. List1
  7. Frame1
  8. Sort by:
  9. Option3
  10. P.O. Box
  11. Option2
  12. First name
  13. Option1
  14. Command4
  15. Delete
  16. Command3
  17. Command2
  18. << Prev.
  19. Command1
  20. Next>>
  21. Line2
  22. Line1
  23. datalabel3
  24. datalabel2
  25. datalabel1
  26. Label3
  27. P.O.Box:
  28. Label2
  29. First Name:
  30. Label1
  31. Name:
  32. about
  33. About
  34.     separator
  35. endprogram
  36. Text1_Change
  37. Data1_Validate
  38. Actionm
  39. Data1_Reposition
  40. label4
  41. Caption
  42. recordcountf
  43. data1F
  44. @    Form_Load
  45. database
  46. table!
  47. RecordSource
  48.     TableDefs
  49. Index&
  50. Connect
  51. DatabaseName
  52. MyTable[
  53. MyDB{
  54. databes*
  55. indexes
  56. fields
  57. Command1_Click
  58. Command2_Click
  59. text1
  60. datasource
  61.     datafiled
  62.     datafield
  63. text2
  64. text3l
  65. refresh_display
  66. Command3_Click
  67. Command4_Click
  68. delte;
  69. Option1_ClickL
  70. Option2_Click
  71. Option3_Click1
  72. about_ClickU
  73. PROGRAM
  74. PETER
  75. SCHULZE
  76. TY1PS
  77. endprogram_Click9
  78. table1
  79. treats
  80.     directory
  81. containing
  82. tables
  83. dbase
  84. routine
  85.     refreshes
  86. Form_Unload
  87. Cancel
  88. datalabel1
  89. datalabel2
  90. datalabel3
  91. moves
  92. record
  93.     according
  94. current
  95. form1
  96. list1
  97. refresh_list
  98. MoveF
  99. newpat
  100. catcherrorz
  101. declare DATABASE as a databasevariable
  102. declare TABLE1 as table variable    
  103. about_Click
  104. DBASE-III File and Index access with VB-3.
  105. Little demoprogram by Peter Schulze, TY1PS. 72253,2602@compuserve.com
  106. Dbase-III Sample
  107. Command1_Click
  108. this moves to the next record in the database according to the current index
  109. Command2_Click
  110. this moves to the previous record in the database according to the current index
  111. Command3_Click
  112. this adds a new record to the tablen
  113.  all index files will be updated automatically
  114. First Name
  115. FIRST_NAME
  116. FIRST_NAME
  117. PO BOX
  118. POBOX
  119. POBOX
  120. Command4_Click
  121.  this removes the current record from the database
  122. endprogram_Click
  123. END the programa
  124. Form_Load
  125.  We first have to open the database.  
  126.  VB-3 treats the directory containing all database file as 'The Database'
  127.  therefore the OpenDatabase command points to a disk directory
  128.  make sure to have the DBF and NDX files in the c:\dbsample directory 
  129.  the two 'false', 'false' declarations assure that the file is openc
  130.  in multiuser mode and for read and write operations
  131. C:\DBSAMPLE
  132. Dbase III;
  133. Please indicate the path where the BBS.DBF file can be found
  134.  now VB knows where to find all information releated to the database. All DBF and NDX filese
  135.  must be in the same directory. 
  136.  Next we select the data we want to work with. This is called a table.
  137.  Each table is represented as a .DBF file. You can have as many tables as you like in 
  138.  a database (=disk directory).
  139.  Each table is kept in a seperate .DBF file.
  140.  in this example we access a Table called BBS.DBFf
  141.  A table contains the actual data as well as the field structures.
  142.  You can create new tables using VB commands but it is much easier
  143.  to use the Datamgr.Exe program that comes with VB for this purpose.
  144.  To create a new table (DBF) file with datamgr select 'Open Database' from the 'FILE' menu.e
  145.  Yes this is a bit strange, the 'new database' menu will not allow for the
  146.  creation of new tables in dbase format, but' 'Open Database' does
  147.  now select 'DBASE-III' and then choose the directory where you want to create the files.
  148.  The 'new table' button now creates new DBF files, whereas you can add .NDX index files with the
  149.  'ADD/DELETE INDEXES' options. More about indexs later.e
  150.  now we have opened the BBS.DBF datafile and it is ready for use
  151.  in order to speed up searches in a database, we have to use what is called Indexes.
  152.  a index is nothing else but sort key for your data.  
  153.  This allows us to quickly change the sort order and search for records withoute
  154.  the need to call a lenghtly sort routine.
  155.  Dbase uses .NDX files to keep indexes. Each index has its own .NDX file.i
  156.  You can have as many NDX files as you wish, but you should keep them to the minimum neededh
  157.  as otherwise keeping track of all the .NDX files will slow your program down. n
  158.  in this sample i have declared 3 Indexes:
  159.  NAME (NAME.NDX) contains the data sorted by name 
  160.  FIRSTNAM (FIRSTNAM.NDX) sorts by the first name
  161.  POBOX (POBOX.NDX) sorts by the boxnumbers
  162.  with these 3 indexes avaiable i can easily change the order of my records by changing
  163.  the index used, without the need to re-sort all data.  
  164.  at startup i select 'name' as index. this means the data will be sorted by name.n
  165.  indexing is also essential to quickly find data in the database. 
  166.  with indexes i can use the very quick 'SEEK' command.
  167.  without indexes i woul have to use 'Findfirst' which is a lot slower.
  168.  now i want to have something on the screen at program start, so i call the 
  169.  routine that refreshes
  170.  my screen
  171.  this ends the initialisation 
  172. Form_Unload
  173.  before ending i have to close my tables and databasem
  174.  this assures that all is written to disk and no data lost
  175. Option1_Click
  176.  i want the data to be sorted by name.
  177.  setting the index to "NAME" does the job 
  178. Option2_Click
  179.  i want the data to be sorted by First name.
  180.  setting the index to "FIRSTNAM" does the jobb
  181. FIRSTNAM
  182. Option3_Click
  183.  i want the data to be sorted by PO-BOX number
  184.  setting the index to "POBOX" does the job
  185. POBOX
  186. refresh_display
  187. this updates my screen P
  188. FIRST_NAME
  189. POBOX
  190. refresh_list
  191.  this updates the list boxes
  192. FIRST_NAME
  193. POBOX
  194.