?
Solved

Parsing a file

Posted on 1998-10-14
2
Medium Priority
?
143 Views
Last Modified: 2010-04-30
Hi,
   I need to be able to parse a file so that it adds four charactors to the end of each line as it stores the file into a variable named CTEXT... any ideas?

Kind Regards,
Rob Green.
0
Comment
Question by:robjgreen
2 Comments
 
LVL 3

Accepted Solution

by:
traygreen earned 120 total points
ID: 1439974
If the file has carriage return/line feed characters in it(or any other identifiable line delimiter character in it) you can run through the file one character at a time.  You can build the output string as you go and replace or append the four characters everytime you hit the delimiter character.

eg.

const cAPPEND_CHARS = "1234"
Dim Char
dim CText as string
 
Open "FILE" For Input As #1      ' Open file.
Do While Not EOF(1)      ' Loop until end of file.
  Char = Input(1, #1)      ' Get one character.
  if asc(Char)<> 13     ' cr/lf
     CText = CText & Char
  else
     CText = CText & cAPPEND_CHARS
  end if      
Loop
Close #1      ' Close file.
0
 

Author Comment

by:robjgreen
ID: 1439975
I actually cracked it before you sent the reply, but thanks for replying so quickly anyway :o)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question