Posted to microsoft.public.excel.misc
|
|
Why Im I getting an error in code..
Thank you JLatham Ill give that a try.
"JLatham" wrote:
Better:
FName = "F:\trial2.txt"
Fnum = Freefile() ' gives next available buffer #
Open FName For Input As #Fnum
Do While Not EOF(Fnum)
Line Input #Fnum,WholeLine
...
...
Loop
Close #Fnum
Since you're only reading it, not really necessary to use the Access Read.
In a way you're assigning a file to a 'variable' when you do the open.
Picture the #1 or #Fnum as assigning a communication path (and more) to that
file.
The Freefile() function returns the next available number for such
operations - they can go from 1 to 255. It's best to use it, especially if
you are working with multiple files.
"N.F" wrote:
Tried the quotations and still didnt work. Hey Rick I expanded on the code so
that u can look at why the For #1 statement does:
I think the #1 statmetnt is referred in the code in the line that states "
Line Input #1. See below
FName = "F:trial2.txt" For Input As #1
Open FName For Input Access Read As #1
............
...........
While Not EOF(1)
Line Input #1, WholeLine
If Right(WholeLine, 1) < sp Then
WholeLine = WholeLine & sp
End If
"Rick Rothstein (MVP - VB)" wrote:
Why Im I getting an error in the partial code below??
Im trying to import a tezt file, but when I try to run it it highlights
the
FName line and says the following messege: "Expected: line# or label or
statement or end of statement"
FName= F:\trial2.txt For Input As #1
I am not sure what the For Input As #1 part is supposed to be doing... you
are just trying to assign the path to the variable, right?
FName = "F:\trial2.txt"
Note the quote marks.
Rick
|