On 21-Jun-2005,
nizar.jouini@webinfo.fi wrote:
[color=blue]
> Hello.
>
> I have long text file whitch is formatted like this:
>
> nextrow4
>
> asdf
>
> asdf
>
> asdf
>
> nextrow3
>
> bsdf
>
> bsdf
>
> bsdf
>
> nextrow6
>
> cdsf
>
> cdsf
>
> cdsf
>
> So the file should look like this after importing
>
> nextrow4 | asdf | asdf | asdf
> nextrow3 | bsdf | bsdf | bsdf
> nextrow6 | csdf | csdf | csdf
>
> So nextrow+"some number" or just nextrow tells to start a new row. The
> linechange is indicating column change.
>
> I'we been trying all kinds of additional software to import the
> textfile but none of them did work the way I needed.
>
> Every help will be respected, thanks!
>
> - Nisse[/color]
You didn't specify much about the text file you are reading. From the way
you formatted the data on screen, I am going to assume that each piece of
text is followed by a carriage return and that a carriage return is on each
of the blank lines between text lines.
Dim tmpStr As String
Dim inputStr() As string ' dimension as needed to handle all entries in
your "long" text file
Dim i As Integer ' index to current row
Dim x As Integer
Open (strPath & "filename.txt") For Input As #1
i = 0
Do While Not EOF(1)
Line Input #1, tmpStr ' Input (instead of Line Input) may work
depending on delimiters in text file
x = InStr(1, tmpStr, "nextrow", vbTextCompare)
If x > 0 Then
' input contains text "nextrow"
i = i + 1
inputStr(i) = tmpStr
Else
inputStr(i) = inputStr(i) & " " & tmpStr " add more spaces or perhaps
a Tab character to get columns right
End If
Loop
Close #1
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---