1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| Public Sub lireDBF(ficdbf$)
Close
Dim a As Byte
Dim b As Byte
Dim C As Byte
Dim d As Byte
Dim ha$
Dim hb$
Dim hc$
Dim hd$
Dim Valeur As Integer
Dim vdbl As Double
Dim lastDate As Date 'Dernière date de modification du fichier.
Dim numBHeader As Integer 'Nombre de bits du header.
Dim numBEnr As Integer 'Nombre de bits par enregistrement.
Dim nc$
Dim cec As Byte 'Numéro du champ en cours
ReDim champ(255)
Open ficdbf$ For Binary Access Read As #1 'Ouverture du fichier en mode séquentiel binaire.
Get #1, , a
Get #1, , b
Get #1, , C
Get #1, , d
ha$ = Hex$(a): If Len(ha$) = 1 Then ha$ = "0" & ha$
hb$ = Hex$(b): If Len(hb$) = 1 Then hb$ = "0" & hb$
hc$ = Hex$(C): If Len(hc$) = 1 Then hc$ = "0" & hc$
hd$ = Hex$(d): If Len(hd$) = 1 Then hd$ = "0" & hd$
hb$ = CByte("&h" & hb$)
hc$ = CByte("&h" & hc$)
hd$ = CByte("&h" & hd$)
If Val(hb$) >= 100 Then hb$ = Str$(2000 + (Val(hb$) - 100)) 'Bug de l'an 2000...
lastDate = CDate(hd$ & "/" & hc$ & "/" & hb$)
Get #1, , a
Get #1, , b
Get #1, , C
Get #1, , d
ha$ = Hex$(a): If Len(ha$) = 1 Then ha$ = "0" & ha$
hb$ = Hex$(b): If Len(hb$) = 1 Then hb$ = "0" & hb$
hc$ = Hex$(C): If Len(hc$) = 1 Then hc$ = "0" & hc$
hd$ = Hex$(d): If Len(hd$) = 1 Then hd$ = "0" & hd$
numEnr = CDbl("&h" & hd$ & hc$ & hb$ & ha$)
Get #1, , a
Get #1, , b
ha$ = Hex$(a): If Len(ha$) = 1 Then ha$ = "0" & ha$
hb$ = Hex$(b): If Len(hb$) = 1 Then hb$ = "0" & hb$
numBHeader = CInt("&h" & hb$ & ha$)
Get #1, , a
Get #1, , b
ha$ = Hex$(a): If Len(ha$) = 1 Then ha$ = "0" & ha$
hb$ = Hex$(b): If Len(hb$) = 1 Then hb$ = "0" & hb$
numBEnr = CInt("&h" & hb$ & ha$)
For i = 1 To 20
Get #1, , a
Next i
nbchamps = 0
cec = 1 'Initialisation du numéro de champ en cours.
header:
Get #1, , a
ha$ = Hex$(a)
If Len(ha$) = 1 Then ha$ = "0" & ha$
If ha$ = "0D" Then GoTo records
Get #1, Seek(1) - 2, a
getDbfFieldHeader (cec) 'Appel de la fonction de lecture du header.
cec = cec + 1
GoTo header
records:
nbchamps = cec - 1
ReDim Preserve champ(nbchamps)
ReDim valchamp(nbchamps, numEnr)
'Call lirecontenu
End Sub |
Partager