Simple Text Editor Tutorial (for noobs)
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
5 posts
Page 1 of 1
Hello this is Jamesgryffindor99 productions and i am presenting you a Simple Text editor tut
You Will Need:
1. a text box (Dock Fill)
a Menu Strip with under File are Open and Save As
Next, Double Click Open and put in the code below
Now, Here is the Code.
You Will Need:
1. a text box (Dock Fill)
a Menu Strip with under File are Open and Save As
Next, Double Click Open and put in the code below
Now, Here is the Code.
Code: Select all
Go back to the designer and double click on and put this code in
Dim open As New OpenFileDialog()
Dim mySreamReader As System.IO.StreamReader
open.Filter = "[*.txt*]|*.txt|All Files[*.*]|*.*"
open.CheckFileExists = True
open.Title = "Open File"
open.ShowDialog(Me)
Try
open.OpenFile()
mySreamReader = System.IO.File.OpenText(open.FileName)
TextBox1.Text = mySreamReader.ReadToEnd()
Catch ex As Exception
End Try
Code: Select all
Now you have a Simple Text Editor!Dim save As New SaveFileDialog()
Dim myStreamWriter As System.IO.StreamWriter
save.Filter = "(*.txt)|*.txt|All Files(*.*)|*.*"
save.CheckPathExists = True
save.Title = "Save File" save.ShowDialog(Me)
Try
myStreamWriter = System.IO.File.AppendText(save.FileName)
myStreamWriter.Write(RichTextBox1.Text)
myStreamWriter.Flush()
Catch ex As Exception
End Try
http://www.sctechusa.com SilverCloud Website
this is very basic, you should have called this tutorial something like "How to use OPEN & SAVE FILE DIALOG"
You can find me on Facebook or on Skype mihai_92b
[*.txt] is not really a description :/
and you can show a message when it failed so save so the user would know what's wrong
change
and you can show a message when it failed so save so the user would know what's wrong
change
Code: Select all
to Catch ex As Exception
End Try
Code: Select all
And it's for noobs , you should really comment the code cooll;Catch ex As Exception
Msgbox(ex.Message)
End Try
You can comment out the line open.OpenFile() unless you are going to use the StreamReader that it returns.
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023