OK, now its time to get serious: it's all well and good to FIND a file, but we want to load it into the textbox on our form. Otherwise, what's the point? So here's what we need to do that:
a "reader" of some kind. We've already used file "writers" to create files and put stuff in them. This is kind of the same only in reverse. Here's what you gotta add to yer code:
'dim a streamreader variable
Dim wordReader As System.IO.StreamReader
'make a new streamreader and pass it the variable
'thats equal to whatever the OpenFileDialog found
wordReader = New System.IO.StreamReader(theFileName)
'set text of the textbox to all the stuff found by the reader
MyWords.Text = wordReader.ReadToEnd
'shut down the reader
wordReader.Close( )
OK, so lets see if you can use this to open a file inside your textbox. Try it out, and understand that it will ONLY look for "Notepad" type files.
As you can see, I have extensively COMMENTED my code, so its pretty darned obvious what the heck all this stuff is for. Ahem!! And btw, I have a final message to Mr. Octopus, Mr. Crab, Mr. StarFish, Mr. Sponge, etc etc etc: you got ZERO credit for the commenting assignment. I don't have the time to figure out who those names are supposed to mean
Cheers,
Mr. L
Saturday, November 8, 2008
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment