help 
Author Message
 help

I need to write a program in Visual Basic to bring in information from an
ascii text file.
Actually, I am writing a modual in Excells visual basic editor.

I need to be able to bring in a single line at a time, compare the first
character, then drop the first character of the line using the Right Most
command, assign the information to a cell, then bring in the next set of
information.

If I use Line Input, it brings in the entire file till EOF.

Is there a way to do this.  I am using the visual basic editor in Excel 7.0

Thanks ahead of time.

Jonathan



Tue, 01 Feb 2000 03:00:00 GMT  
 help

Hello Jonathan,

It sounds to me like your lines are not terminated by a CR_LF pair.  Most
likely these are text files from a UNIX based system, and they only have the
LF character not the CR_LF used by MS Dos and Windows based systems.  You
have two options.  One, if you know how long the records are, you could use
the Input function instead of the Line Input function and specifiy a record
length.  Second, if you can determine that each line is terminated by a LF
(or a CR but not both) then you could using a loop read each character in
until you find the terminating character, then process that line and move
on.  For example:

Dim strLine as String
Dim strChar as String * 1
Dim lngFile as Long

lngFile = FreeFile
Open "C:\temp.txt" For Input Access Read Shared As lngFile

Do Until EOF(lngFile)
    strChar = Input 1, #lngFile
    If strChar = vbLF Then
        ' process strLine
        strLine = ""
    else
        strLine = strLine & strChar
    End if
Loop

Close lngFile

I hope this helps,

--

Larry R. Tubbs Jr., MCPS, MCSD
Silverleaf Resorts Inc, NYSE: SVR

http://www.geocities.com/ResearchTriangle/5727/

Jonathan Wood wrote in article

Quote:
>I need to write a program in visual basic to bring in information from an
>ascii text file.
>Actually, I am writing a modual in Excells visual basic editor.

>I need to be able to bring in a single line at a time, compare the first
>character, then drop the first character of the line using the Right Most
>command, assign the information to a cell, then bring in the next set of
>information.

>If I use Line Input, it brings in the entire file till EOF.

>Is there a way to do this.  I am using the visual basic editor in Excel 7.0

>Thanks ahead of time.

>Jonathan



Tue, 01 Feb 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. help,help,help,help,help,help,help,help,help,help,help,help,help,

2. Help,Help,Help,Help,Help,Help,Help,Help,Help,Help,Help,Help,Help,Help,Help,Help,Help,Help,

3. Help, Help, Help, Help, Help, Help, Help, Help, Help, Help, Help, Help, Help, Help, Help, Help, Help,

4. HELP HELP HELP HELP HELP HELPHELP HELP HELPHELP HELP HELP

5. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

6. HELP HELP HELP HELP HELP HELP HELP HEL P HELP HE LP HELP HELP HEL P HELP HELP

7. Help Help Help Help Help Help !!!!!

8. HELP HELP HELP Set document name of print job from VB HELP HELP HELP

9. HELP HELP HELP Early Binding Excel 5.0 HELP HELP HELP

10. HELP HELP HELP HELP HELP

11. Help - Print - Help -Print - Help - Print - Help - Print - Help

12. help help help help help

 

 
Powered by phpBB® Forum Software