-
I'm trying to read each line of a text file into an array, I'm using vbCrLf as the delimiter but the whole file is being read into the first elemnt. I'm using the split function but it doesn't seem to like it. Can anyone see where I'm going wrong?
FileName = Command() + "nng_list.TXT"
FileNumber = FreeFile
'Open file and read lines
Open FileName For Input Access Read As #FileNumber
Do Until EOF(FileNumber)
'Assign content to variable
Line Input #FileNumber, Data
'Create New File of type *.DAT for use in SQL*Loader.exe
WriteFile = Command() + "nng_list.DAT"
WriteFileNumber = FreeFile
'Open New File for writing to
Open WriteFile For Append Access Write As #WriteFileNumber
'Split function to disect data
Datak = Split(Data, vbCrLf)
'Datak = Split(Data, "#", -1)
'Discard unwanted data
Print #WriteFileNumber, Datak()
Loop
Cheers all
-
<?>
there is an an example of split and reading a split found Here . Perhaps it will help.
-
Hi Skeen !!!
Your problem is in the split command !!!
if you use input to open a file the line delimiter is vbcrlf
in your case u have maybe a file from a unix system.
Unix systems use as default vbcr or vblf as line delimiter.
so change the line
Code:
Datak = Split(Data, vbCrLf)
'to
Datak = Split(Data, vbCr)
'or
Datak = Split(Data, vbLf)
hope this helps
-cu TheOnly
-
Nice 1 Brother
Cheers man
I'm a bit of a unix virgin and integrating NT and Unix is a bit confusing to me at the moment.
Thanx again
-
You Da Man!
Yeah TheOnly
You da man - I've been at that for 2 dayz, worked a fookeen charm.
Cheers m8
skeen