how to pull text from text file

im making this program which converts txt file in tiff files.
the txt file contains my corporations employee records
so i have the program break it up and make it different tiff files
i need to pull all of the ssn's from the text file

how do i pull that from the text file and put it in another text file

remember this is for VB
jrisi03Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JacamarCommented:
Ok, assuming that your textfile is comma delimitted. (format as follows)


First, Last, age
Bob, McDonald, 32
Joe, Sampson, 30
ect....

to input the text and create 3 files (one for first, one for last, and one for age) paste the following code.

dim stFilename as string
dim array1() as string

stFilename = app.path & "\Employee.txt"

Open stFilename for input as #1
Redim array1(1 to 3, 1 to 1)
Input #1,array1(1,1)
Input #1, array1(2,1)
Input #1, array1(3,1)
inI = 1
Do while not EOF(1)
inI = inI + 1
Redim array1(1 to 3, 1 to inI)
Input #1, array1(1,inI)
INput #1, array1(2,inI)
INput #1, array1(3,inI)
Loop

Close #1

stFilename = app.path & "\Firstname.txt"
Open stFilename for output as #2

For inJ = 1 to inI
Print #1, array1(1,inI)
Next inJ
Close #2

stFilename = app.path & "\Lastname.txt"
Open stFilename for output as #3

For inJ = 1 to inI
Print #1, array1(2,inI)
Next inJ
Close #3

stFilename = app.path & "\Age.txt"
Open stFilename for output as #4

For inJ = 1 to inI
Print #1, array1(3,inI)
Next inJ
Close #4

End sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rspahitzCommented:
The other method would be to extract the SS# from a fixed position, which is done using the substring functions: left$, mid$, right$.

Most likely, your code would look like this for fixed-position values:

open "SomeFile.txt" for binary as #1
strTextFileData = input$(lof(1), #1)
close #1

strSSN = mid$(strTextFileData, intStartPosition, 11) ' 11-character SS# including dashes
0
coreytheBMXprogrammerCommented:
You could use jacamar's code but change some code to allow an undefined number of conversions. Just use a few more variables to do it and put in in a loop.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.