Need help with parsing a text file. [Archive] - SpeedGuide.net Broadband Community

View Full Version : Need help with parsing a text file.


Hieysk
02-28-02, 05:58 PM
Im trying to write a VB app that will read in a text file line by line and "look" for certain things then add that instance to a variable that I choose.

Sample text file line:

"The brown dog sits down in the chair and eats 3 biscuits".

As my end product I want to give the user the stats on

a. What color dog
b. Sat where
c. Eat X number of buscuits.


I need help with coding the "if you find this______ add it to this variable.. Or... whatever..


Anyone have any ideas on one of the better ways to do this?

Thanks.

RoundEye
03-23-02, 03:09 AM
bump

corkymccorkle
04-03-02, 09:45 PM
you would have to write some pretty intense coding, or you might just be able to use substring functions such as

stringA = "abcdefg"
part1OfStringA = Left(stringA, 1) ' Stores a
part2OfStringA = Left(stringA, 3) ' Stores abc
part3OfStringA = Left(stringA, 20) ' Stores abcdefg

part4OfStringA = Right(stringA, 1) ' Stores g
part5OfStringA = Right(stringA, 3) ' Stores efg

'Mid(string, start, length

part6OfStringA = Mid(stringA, 2,2 ) ' Stores bc
part6OfStringA = Mid(stringA, 3,2 ) ' Stores cd

, umm let me dig up a project that i did and i'll paste the code that i used to see if a certain character( a tilde ~) was detected.

Ghosthunter
04-28-02, 02:13 AM
Perl is a much better way to do it.

I am assuming you want to use windows platform which is not a problem, just download and install Active perl for win32

I am not at work right now but I have some scripts that I have setup to do something similar you want. I can paste here, and then you can take what you need.