![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
This vb code to convert database dbf file to asccii csv format you can open the file then as text file. I am saving the file to "c:\" as table.txt. you need: 1.create form 2.add common dialoge 3.add command button 4. copy and paste code hope someone can develope it to some thing better. Walid New Zealand ';; ! ************************************************** ************************* ';; ! dbf to csv ';; ! ************************************************** ************************* ';; ! Function : Create csv file from dbf file ';; ! Updated : Sept 08, 2004 ';; ! (C) 1999-2004, Geographic Information System, Rodney District Council ';; ! Contact :Walid Ismail Al Tiay ';; ! ';; ! ';; ! ************************************************** ************************* snip For I = 0 To UBound(FieldNames) lngFieldLen = FieldNames(I).FieldLength + 15 For J = 1 To lngFieldLen On Error Resume Next strTemp = strTemp & Chr$(p_bytRecord(J + position)) Next snip |
#3
| |||
| |||
|
|
This vb code to convert database dbf file to asccii csv format you can open the file then as text file. I am saving the file to "c:\" as table.txt. you need: 1.create form 2.add common dialoge 3.add command button 4. copy and paste code hope someone can develope it to some thing better. Walid New Zealand ';; ! ************************************************** ************************* ';; ! dbf to csv ';; ! ************************************************** ************************* ';; ! Function : Create csv file from dbf file ';; ! Updated : Sept 08, 2004 ';; ! (C) 1999-2004, Geographic Information System, Rodney District Council ';; ! Contact :Walid Ismail Al Tiay ';; ! ';; ! ';; ! ************************************************** ************************* Option Explicit Dim fdesc As FdescriptorArray Private Sub Command1_Click() Dim sfile As String Dim sfile2 As String With CommonDialog1 .DialogTitle = "Open" .CancelError = False .FileName = "" .Filter = "DBase III Files (*.DBF)|*.DBF|All Files (*.*)|*.*" .ShowOpen If Len(.FileName) = 0 Then Exit Sub End If sfile2 = .FileTitle sfile = .FileName End With Open "c:\table.txt" For Output As #1 ParseDBase sfile, sfile2 End Sub Function ParseDBase(p_strFileName As String, p_strFileName2 As String) As String Dim Version As Byte Dim intFF As Integer Dim lngNumRec As Long Dim intHLen As Integer Dim intRLen As Integer Dim strLASTUPD As String * 3 Dim bytIncTrans As Byte Dim bytEncFlag As Byte Dim DbaseContainer As String * 263 Dim pointer As Long Dim record() As Byte Dim FieldNames() As FdescriptorArray Dim strTemp As String Dim I As Integer Dim lngCounter As Long Dim msg As String intFF = FreeFile Open (p_strFileName) For Binary Access Read As #intFF Get #intFF, 1, Version 'DBase Version Get #intFF, 2, strLASTUPD Get #intFF, 5, lngNumRec 'Records Get #intFF, 9, intHLen Get #intFF, 11, intRLen Get #intFF, 33, fdesc ReDim record(1 To intRLen) As Byte ReDim FieldNames(0 To 0) pointer = 33 + Len(fdesc) Do Until pointer >= intHLen Get #intFF, pointer, fdesc ReDim Preserve FieldNames(0 To UBound(FieldNames) + 1) FieldNames(UBound(FieldNames) - 1) = fdesc pointer = pointer + Len(fdesc) Loop lngCounter = 1 Do Until EOF(intFF) strTemp = "" Get #intFF, , record ParseRecord FieldNames, record, lngCounter lngCounter = lngCounter + 1 Loop Close #intFF Close #1 MsgBox "Done....." End Function Private Sub ParseRecord(FieldNames() As FdescriptorArray, p_bytRecord() As Byte, p_lngCounter As Long) Dim J As Integer Dim I As Integer Dim position As Integer Dim strTemp As String Dim msg As String Dim lngFieldLen As Long On Error GoTo Errorhandler position = 0 For I = 0 To UBound(FieldNames) lngFieldLen = FieldNames(I).FieldLength + 15 For J = 1 To lngFieldLen On Error Resume Next strTemp = strTemp & Chr$(p_bytRecord(J + position)) Next If I <> UBound(FieldNames) Then msg = msg & "," & Trim$(strTemp) Else Print #1, msg & "," & Trim$(strTemp) End If position = position + lngFieldLen strTemp = "" Next Errorhandler: End Sub Private Sub Form_Load() Command1.Caption = "Open" End Sub Private Sub Form_Unload(Cancel As Integer) End End Sub |
![]() |
| Thread Tools | |
| Display Modes | |
| |