Solved

Parsing a file

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel VBA combine two working workbooks 8 47
VB 6.0 printer how to align 6 58
Computer crashes, following error message in event manager 5 141
Add and format columns in vb6 7 47
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…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now