Export records to a Text file
- From: Opyuse <Opyuse@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 2 Jun 2005 05:01:03 -0700
Howdy,
I used the following code to import records from a Tab deliminated file.
ff = FreeFile
Open "a:\CustomerDatabase.txt" For Binary As #ff
Raw$ = String$(LOF(ff), 0)
'Read the entire file in one operation and close it
Get #ff, 1, Raw$
Close #ff
ReDim Txt$(0)
Do
Cloc = InStr(Raw$, vbCrLf)
If Cloc > 0 Then 'Parse the data
ReDim Preserve Txt$(0 To UBound(Txt$) + 1)
Tmp$ = Left$(Raw$, Cloc - 1)
Txt$(UBound(Txt$)) = Tmp$
Else
Exit Do 'All data has been parsed
End If
Raw$ = Right$(Raw$, Len(Raw$) - (Len(Tmp$) + 2))
Loop
Dim line As String
Dim count As Integer
Dim RunningCount As Integer
count = 0
RunningCount = 0
For n = 0 To 3600
line = Txt$(n)
For m = 1 To Len(line)
Letter = Mid(line, m, 1)
If Letter = vbTab Then
count = count + 1
'add to text field
Select Case count
Case 1:
txtSname = Mid(line, 1, RunningCount)
NextStart = m + 1
RunningCount = 0
Case 2:
etc
Each line of the code represented a complete record. Each line was placed
into the array Txt$.
I then set a For loop to go thought each of the aray elements and added them
to the text fields in my application.
Then used datPrimaryRS.Recordset.AddNew to add the record to my Informix
database.
What I need to do now is reverse this so I can export to excel.
Unsure of the best way to do this. Can you help?
Is this the best why to do this or is there another method easy thten what I
have planed.
.
- Follow-Ups:
- RE: Export records to a Text file
- From: VN
- RE: Export records to a Text file
- Prev by Date: odbc driver to filemaker file
- Next by Date: IIS 6.0 web won't connect to SQL2000 db server
- Previous by thread: odbc driver to filemaker file
- Next by thread: RE: Export records to a Text file
- Index(es):
Relevant Pages
|
Loading