I have written a text editor for an assignment and have found a few faults with it im hoping someone could help me out.
First one is my save menu option, when I click Save in the file menu, it brings up the save as dialog box as apposed to just updating the file. Please see below the code I have for it, if anyone could tell me what I need to change my code to it would be much appreciated.
Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click, SaveToolStripMenuItem.Click Dim CurrentFile As String = "Untitled Document" If CurrentFile <> "Untitled Document" Then My.Computer.FileSystem.WriteAllText(CurrentFile, txtBox.Text, False) Else SaveAsToolStripMenuItem.PerformClick() End If End Sub
Second thing is, I have set up a customise menu so that you can change the font type, font colour, but what seems to be happening is that I highlight the text I want to change select my changes through my menu options but all the text on the page changes? Below is the code I have written, can anyone tell me what I need to change to make this only change the text I highlight.
Private Sub SetFontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SetFontToolStripMenuItem.Click If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then txtBox.Font = FontDialog1.Font End If End Sub Private Sub SetFontColourToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SetFontColourToolStripMenuItem.Click If ColorDialog1.ShowDialog = DialogResult.OK Then txtBox.ForeColor = ColorDialog1.Color End If End Sub
Any help would be greatley appreciated