Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i convert dbase file(file1.dbf) to text file (file1.txt)?

Status
Not open for further replies.

Oliver76

Programmer
Oct 2, 2001
60
0
0
Greetings!!!

I was trying to import dbase file to an accounting software. But it only accepts .txt files. How can i convert this dbase file to text files programmatically using VB6.


thanx in advance.

oliver
 

Use DAO and JET.
Make the connection on the dbf db.
Use an action query (SELECT INTO) and the 'INI' clause to take the data from a table and export it to the ascii file, all in one shot.
 
Tnx CCLINT, I coded it like this but the output doesnt fit what I want. Is there something wrong?
Please Help.

here's my code:
Private Sub Command1_Click()
Dim i As Integer
Open "C:\windows\Desktop\Export.txt" For Output As #1
For i = 1 To Data1.Recordset.RecordCount

Print #1, Tab(4); Data1.Recordset!name
Print #1, Tab(4); Data1.Recordset!surname
Print #1, Tab(4); Data1.Recordset!age
Print #1, Tab(4); Data1.Recordset!address
Data1.Recordset.MoveNext
Next i
Close #1
End Sub

This is the OUTPUT:

oliver
fesniak
26
Tacloban City

Mario
Writes
21
LA

Joel
Young
23
Maryland

How can i make it look like this:

oliver fesniak 26 tacloban City
mario writes 21 LA
Joel young 23 Maryland

Thanx in advance


 
Try change to

Print #1, Tab(4); Data1.Recordset!name;
Print #1, Tab(14); Data1.Recordset!surname;
Print #1, Tab(24); Data1.Recordset!age;
Print #1, Tab(34); Data1.Recordset!address  

Note the ";" at the end of first 3 lines and different TAB positions (you may need to ajust them).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top