Export records to a Text file



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.
.



Relevant Pages

  • RE: count data
    ... > Dim rng As Range ... > lastcol = Cells.End.Column ... > End Sub ... >> if and if only two difrent data are found in cells on the same raw will be ...
    (microsoft.public.excel.programming)
  • Get RAW Bitmap Data from a file
    ... as I am not sure I am getting the correct "raw" image from the file. ... However, when I print what I think is the raw data, I get the image ... Dim bmBitmap As Image = New Bitmap ... Dim rawImage() As Byte = Nothing 'the image as a byte ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Date Question
    ... "Bob Leffew" wrote in message ... > dim MonthNow as date ... date and then converting the raw number back to a date... ...
    (microsoft.public.vb.general.discussion)

Loading