I think this is familiar simple question. I know, famous last words. I've got most of it done. What I'm trying to do if is the user hits Save when there hasn't been a file previously saved or opened, to just go to the Sub mnuFileSaveAs_Click routine that has already been created. I could just create a new sub like SaveAs(), but just seems like a waste to just have the mneFileSaveAs to just reference it.
I just don't know how to do this without creating a SaveAs sub. I've tried just adding mnuFileSaveAs_Click after the strFileName = String.Empty If-Then statement. I even tried using a Call mnuFileSaveAs
Basically, in an assignment I'm creating menustrip items, Save and Save As.
My textbook had one example program with a Save and SaveAs subs. In that example, the only different before the two was the If-Then empty.string for the filename text. I assuming it may be better to reference, if possible, the SaveAs rather than rewriting it.
Thanks for any help and guidance in advance.
I just don't know how to do this without creating a SaveAs sub. I've tried just adding mnuFileSaveAs_Click after the strFileName = String.Empty If-Then statement. I even tried using a Call mnuFileSaveAs
Basically, in an assignment I'm creating menustrip items, Save and Save As.
Code:
Private Sub mnuFileSaveAs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileSaveAs.Click
sfdSaveFile.Filter = "Text File (*.txt)|*.txt"
sfdSaveFile.Title = "Save File"
If sfdSaveFile.ShowDialog = Windows.Forms.DialogResult.OK Then
strFileName = sfdSaveFile.FileName
SaveFile()
End If
End Sub
Code:
Sub SaveFile()
Dim outputFile As StreamWriter
Try
outputFile = File.CreateText(strFileName)
For intCounter = 0 To intSUPER_SCRIPT
outputFile.WriteLine(intRandomNumbers(intCounter))
Next
outputFile.Close()
MessageBox.Show("Save complete", "Save File")
Catch ex As Exception
MessageBox.Show("could not save to file" & ControlChars.CrLf & ex.Message, "Save Error")
End Try
End Sub
Code:
Private Sub mnuFileSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileSave.Click
If strFileName = String.Empty Then
[do not know how to call mnuSaveAs sub]
Else
SaveFile()
End If
End Sub
Thanks for any help and guidance in advance.