Hello there

I have two questions, though one is only small.


I have been using VB for a few days now and the program i have been making works well. i decided to put a menu bar in to save open etc. but i'm having difficulties with the code. the open/save dialog windows open well but it doesn't save/open here are the codes: to open the savefiledialog:

Code Snippet
SaveFileDialog1.InitialDirectory = "C:\"
SaveFileDialog1.Title = "Save a Text File"
SaveFileDialog1.Filter = "Text Files(*.txt)|*.txt"
SaveFileDialog1.FileName = ""
SaveFileDialog1.OverwritePrompt = True

to open the openfiledialog:
Code Snippet
OpenFileDialog1.InitialDirectory = "C:\"
OpenFileDialog1.Title = "Open a Text File"
OpenFileDialog1.Filter = "Text Files(*.txt)|*.txt"
OpenFileDialog1.FileName = ""

these codes work but it's the follow codes that i get errors in:
Code Snippet
Dim FILE_NAME As String = SaveFileDialog1.FileName
Dim i As Integer
Dim aryText(4) As String

aryText(0) = (start.Text)
aryText(1) = (num1.Text)
aryText(2) = (num1.Text)
aryText(3) = (ans.Text)
aryText(4) = (time.Text)

Dim objWriter As New System.IO.StreamWriter(FILE_NAME)

For i = 0 To 4


Code Snippet
Dim FILE_NAME As String = OpenFileDialog1.FileName
Dim TextLine As String
Dim objReader As New System.IO.StreamReader(FILE_NAME)

Do While objReader.Peek() <> -1
TextLine = TextLine & objReader.ReadLine() & vbNewLine

Textbox1.Text = TextLine

I am getting errors in the lines
Code Snippet
Dim objReader As New System.IO.StreamReader(FILE_NAME)

Code Snippet
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)

the error is:
"A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll"
Does anybody know the problem(s)
this is propably a slightly stupid question, but...where should this code actually go should it go before, or after, or some before and some after

Re: Visual Basic Express Edition Saving/opening errors


activate this code when the user tries to save:

Code Snippet,textbox1.text)

That code will save the contents of textbox1 to the directory form the save dialog

open file dialog:

Code Snippet

textbox1.text =,textbox1.text)