Solved

Parsing a file

Posted on 1998-10-14
2
134 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 60 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 58
Hide vba in gp 7 104
How to measure sizes and angles in scanned images ? 3 76
Collapse and expand table in Word 2010 2 36
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

828 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