Advertisement
2002VB Databases/ Data Access/ DAO/ ADO #18836

Read DBF structure and Record count

Returns instant record count, structure of DBF files

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Function dbfStru(file As String) As Double
  Dim fileno As Integer, txtin As Variant, bit(0 To 31) As Double
  Dim posRec As Single, recSize As Single, nmbFiel As Single, fieldName As String
  Dim fieldlength As Single
  Dim test As Single
  fileno = FreeFile
  Open file For Binary As #fileno
  'reads first 31 bites
  For x = 0 To 31
    txtin = Asc(Input(1, #fileno))
    Select Case x
      'record count
      Case 4 To 11
        bit(x) = txtin
    End Select
  Next
  dbfRecCount = bit(4) + (bit(5) * 256) + (bit(6) * 65536) + (bit(7) * 16777216)
  posRec = bit(8) + bit(9) * 256
  nmbfield = (posRec - 33) / 32
  recSize = bit(10) + bit(11) * 256
    For i = 32 To posRec - 1
    'field name
    For n = 0 To 10
      txtin = Input(1, #fileno)
      fieldName = fieldName + txtin
    Next
    fieldName = Trim(fieldName)
    'field type byte 11
    fieldType = Input(1, #fileno)
    'byte 12 to 15
    txtin = Input(4, #fileno)
    
    'byte 16
    fieldlength = Asc(Input(1, #fileno))
    'byte 17
    fieldDeci = Asc(Input(1, #fileno))
    
    For n = 18 To 31
      txtin = Input(1, #fileno)
    Next
    fieldName = ""
  Next
  Close fileno
End Function
Original Comments (3)
Recovered from Wayback Machine