![]() |
Problem reading text file
"cum.nex" wrote:
Dim thisLine(500) As String [....] 2) read each line from this file Input #1, thisLine I believe you should use Line Input, not Input. And either you should use: Dim thisline as String or Dim thisLine as String*500 depending on your intent. I would opt for the first form. Alternatively, perhaps you want: Line Input #1, thisLine(i) where "i" is incremented for each read. ----- original message ----- "cum.nex" wrote in message ... From an Ecel-VB macro I need to do the following: 1) open a text file for reading (in my case. a mail message file) Dim fileIn As String Dim thisLine(500) As String Open fileIn For Input As #1 Open fileOut For Output As #2 2) read each line from this file Input #1, thisLine 3) process the line and then write it to an output text file, similar to the input one. Problem. Lines like the following ones (I add CRLF to display the carriage return chars): Received: from smtp-in10.gmail.com (192.168.32.68) by ims88c.gmail.com (18.0.024.3)CRLF id 47DA621000B94BAB for ; Wed, 28 May 2008 20:00:24 +0200CRLF Received: from outrelay05.gmail.com (172.31.0.121) by smtp- in10.gmail.com (7.3.120)CRLF id 4611FE643F754F89 for ; Wed, 28 May 2008 20:00:24 +0200CRLF are read from the macro as: Received: from smtp-in10.gmail.com (192.168.32.68) by ims88c.gmail.com (18.0.024.3) id 47DA621000B94BAB for ; WedCRLF 28CRLF May 2008 20:00:24 +0200CRLF Received: from outrelay05.gmail.com (172.31.0.121) by smtp- in10.gmail.com (7.3.120) id 4611FE643F754F89 for ; WedCRLF 28CRLF May 2008 20:00:24 +0200CRLF That is: 1) spaces at the beginning of the line are trimmed (" id 4611FE643"...) 2) lines are split ("Wed, 28 May"...) Why and which solution? Thanks. |
Problem reading text file
On 25 Mag, 12:15, "JoeU2004" wrote:
"cum.nex" wrote: * *Dim thisLine(500) As String [....] 2) read each line from this file * * * *Input #1, thisLine I believe you should use Line Input, not Input. And either you should use: Dim thisline as String or Dim thisLine as String*500 depending on your intent. *I would opt for the first form. Alternatively, perhaps you want: Line Input #1, thisLine(i) where "i" is incremented for each read. ----- original message ----- "cum.nex" wrote in message ... From an Ecel-VB macro I need to do the following: 1) open a text file for reading (in my case. a mail message file) * *Dim fileIn As String * *Dim thisLine(500) As String * *Open fileIn For Input As #1 * *Open fileOut For Output As #2 2) read each line from this file * * * *Input #1, thisLine 3) process the line and then write it to an output text file, similar to the input one. Problem. Lines like the following ones (I add CRLF to display the carriage return chars): Received: from smtp-in10.gmail.com (192.168.32.68) by ims88c.gmail.com (18.0.024.3)CRLF * * * *id 47DA621000B94BAB for ; Wed, 28 May 2008 20:00:24 +0200CRLF Received: from outrelay05.gmail.com (172.31.0.121) by smtp- in10.gmail.com (7.3.120)CRLF * * * *id 4611FE643F754F89 for ; Wed, 28 May 2008 20:00:24 +0200CRLF are read from the macro as: Received: from smtp-in10.gmail.com (192.168.32.68) by ims88c.gmail.com (18.0.024.3) id 47DA621000B94BAB for ; WedCRLF 28CRLF May 2008 20:00:24 +0200CRLF Received: from outrelay05.gmail.com (172.31.0.121) by smtp- in10.gmail.com (7.3.120) id 4611FE643F754F89 for ; WedCRLF 28CRLF May 2008 20:00:24 +0200CRLF That is: 1) spaces at the beginning of the line are trimmed (" * * * *id 4611FE643"...) 2) lines are split ("Wed, 28 May"...) Why and which solution? Thanks. It works, thank you! |
All times are GMT +1. The time now is 12:35 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com