Reading a textfile

gomindi

Active member
Joined
Aug 28, 2002
Messages
25
Location
UT
Ive come across another delima. I have written to a textfile, but I need a "separator" so that my data can be read into my text boxes. Can somebody please help me?! I am lost:(

Thanks! Mindi
 
Whats the format of your textfile right now? Can you paste an
excerpt from it so that I know exactly what you need?
 
the format is simply a text file. .txt

thisistochecktoseeifthiscreatesanewfile

I want each word(I typed each word into a separate text box, write to a file) and now I want each word to show up on a form, each in its own text box.
 
Oh, ok. Then when you write the text file, add some delimeter (a
comma, or something; make sure it doesnt appear in any of the words
you want to retrieve from the file). So your file might looks like this:

The,quick,brown,fox,jumps,over,the,lazy,dog

When you read the textfile, read it all in at once, and use the Split
function of the string you read it into, like
Code:
Dim words() As String
Dim fileIn As String

Read your file into the fileIn variable here

words = fileIn.Split(",")
And now you will be left with words(), an array of strings containing
all of the words from your text file. Loop through them and do whatever
you wish with them (adding them to textboxes, I guess).
 
Uh, I am a beginner (as if you couldnt tell!) but could you maybe help me with the code for read your file into the filein variable portion? Sorry I know this is probably super menial to you. But I really appreciate your help!!! THanks! Mindi
 
Try something like this:
Code:
Dim fileIn As String
Dim sr As New IO.StreamReader("C:\file.txt")

fileIn = sr.ReadToEnd()
sr.Close()
 

Similar threads

U
Replies
0
Views
53
Umair Aslam Bhatti
U
S
Replies
0
Views
57
sva0008
S
J
Replies
0
Views
59
Jalil Sear [MCPD SharePoint]
J
T
Replies
0
Views
127
tinst
T
Back
Top