I want to make a text editor in vb.net, a proper one that lets you save files, but all the examples i have found dont allow you to save, only do pointless stuff like change the colour. Can anyone help?
No, as far as i can remember you need to use something called IOstream or reader or something like that
Because that is pseudo code, code that represented in generic format so it is simple to translate to another language. In you case VB.NET.
"You can't be something your not,
Be yourself by yourself
Stay away from me" ~Walk, Pantera
"Playing an acoustic guitar is like having sex with your clothes on" ~Dave Mustaine
RE: Making a text editor in VB.net 08
Posts: Location: Joined: 01.01.70 Rank: Guest
Posted on 27-07-09 00:52
Here is a piece of code from one of my projects. It still needs to be refined, and I'm sure there are other way to do it, but this is how I did it:
'The code in the most of this is for a function like "Save As" like in most text editors
Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveAsToolStripMenuItem.Click
' Create a SaveFileDialog to request a path and file name to save to.
Dim saveFile1 As New SaveFileDialog()
saveFile1 = SaveFileDialog1
Dim JDBoolean As Boolean 'JD stands for JohnDoe since its just random, it will be used to declare if the Form should use the FileSaveDialog's Name
JDBoolean = False
' Initialize the SaveFileDialog to specify the RTF extension for the file.
saveFile1.DefaultExt = "*.txt"
saveFile1.Filter = "TXT Files|*.txt"
' Determine if the user selected a file name from the saveFileDialog.
If (saveFile1.ShowDialog() = System.Windows.Forms.DialogResult.OK) _
And (saveFile1.FileName.Length) > 0 Then
' Save the contents of the RichTextBox into the file.
JDBoolean = True
Else : MessageBox.Show("You must enter a file name")
JDBoolean = False
'The next few lines of code are for a button such as "Save" which is found in most text editors
Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
'Using SaveFile Method to save text in a rich textbox to hard disk
Hope this helps
Hellbound Hackers is the collective work of the staff and the community and is therefore licensed under the CC BY-NC-SA license.