DbStructure




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










( dbstructure.html )- by Paolo Puglisi - Modifica del 17/12/2023