VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Read FoxPro DBF Structure

by Muminrz (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Fri 27th February 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Read FoxPro DBF Structure

Rate Read FoxPro DBF Structure



'Add Microsoft DAO 3.6 Object Library from your (Project -> References)

'Step 2 
 Create Listview fields 
Dim addinfo As ListItem

ListView1.View = lvwReport
ListView1.ListItems.Clear
ListView1.ColumnHeaders.Clear
ListView1.ColumnHeaders.Add , , "Field:", ListView1.Width / 14
ListView1.ColumnHeaders.Add , , "Name:", ListView1.Width / 6
ListView1.ColumnHeaders.Add , , "Type:", ListView1.Width / 8.5
ListView1.ColumnHeaders.Add , , "Start:", ListView1.Width / 13
ListView1.ColumnHeaders.Add , , "End:", ListView1.Width / 13
ListView1.ColumnHeaders.Add , , "Length:", ListView1.Width / 11

'Step 3
Call Function

call ReadDBFlayout("C:\TEMP","DBF_FILE) 'less then 9 Character only

Function ReadDBFlayout(byval path as string, file as string)
Dim i As Long
Dim Pos_S  As Long
Dim Pos_E  As Long
Dim Lpos As Long

On Error GoTo ErrKill
      
   
   Set dbd = OpenDatabase(Path, False, False, "dBASE IV;")
   Set dbf = dbd.OpenRecordset(FILE)
   

      ListView1.ListItems.Clear
   
   
   For i = 0 To dbf.Fields.Count - 1
      
       If Val(i) = 0 Then
          Pos_S = 1
          Pos_E = dbf.Fields(i).Size
       Else
          Pos_S = Pos_E + 1
          Pos_E = Pos_E + dbf.Fields(i).Size
       End If
        
  
Set addinfo = ListView1.ListItems.Add(, , CStr(i) + 1)
    addinfo.SubItems(1) = dbf.Fields(i).Name
    addinfo.SubItems(2) = dbf.Fields(i).Type
    addinfo.SubItems(3) = CStr(Pos_S)
    addinfo.SubItems(4) = CStr(Pos_E)
    addinfo.SubItems(5) = dbf.Fields(i).Size
       
       Lpos = Lpos + dbf.Fields(i).Size - 2
              Next i
   
dbd.Close

Exit Function


ErrKill:
    Exit Function  
Function


Download this snippet    Add to My Saved Code

Read FoxPro DBF Structure Comments

No comments have been posted about Read FoxPro DBF Structure. Why not be the first to post a comment about Read FoxPro DBF Structure.

Post your comment

Subject:
Message:
0/1000 characters