Tuesday, November 11, 2008

Wed Nov 12: modifying the SAVE menu item, part one

Hey there fellow coders!

Here's how we can dramatically revamp your menu project, so that you can open an existing file, make some changes to it, then save the changes to that SAME file, in it's same location.

Here's what you do:

A) MOVE this line of code

Dim theFileName As String

from the place its in now to just below "Public Class Form1"
that way both the "Open" and "Save" menu items will be able to use it :-)

B) rip out all that crap that we have in the current SAVE menu item code, and replace it with this:

'dim a streamwriter variable
Dim wordWriter As System.IO.StreamWriter
'make a new streamwriter and pass it the variable
'thats equal to whatever the OpenFileDialog found
wordWriter = New System.IO.StreamWriter(theFileName)
'set text of the textbox to all the stuff found by the reader
wordWriter.Write(MyWords.Text)
'shut down the writer
wordWriter.Close( )

I swear to GOD, it really is that simple! Let's make sue that all have it working, OK?

Cheers,
Mr. L

No comments: