Page 1 of 1

[Tut]- How to make text editor in VB

Posted: Thu Nov 17, 2005 5:22 pm
by scubakobe
Lets learn how to make a simple Text editor with Open/Save functions.
Note: I am using Microsoft Visual Basic 2005 Express Edition

1 Start off by making a new "Windows Application" or exe.
2 If using VB 2005 then drag the preset "MenuStrip" on to the top of the Form.
Image
3 Now where it says "Type Here" in the menu strip, type Open Document. When you click to change what it says you will notice that a menu pops up below it, ignore that and still type Open document where you saw Type Here first. Once you are done typing that in, move your mouse right next to where you typed Open Document, then click down. Another box that says Type Here should pop up. In that one type Save Document.
Image
4 Now drag in a RichTextBox into the form, then make it any size you want.
5 Now double click where it says Open Document, and the script editor should come up. The script shown should look like this....
Public Class Form1

Private Sub OpenDocumentToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenDocumentToolStripMenuItem.Click
Below all of that code paste in this:
Dim dlg As OpenFileDialog = New OpenFileDialog

dlg.Filter = "Text Files (*.txt) |*.txt"

If Windows.Forms.DialogResult.OK = dlg.ShowDialog Then

Dim sr As System.IO.StreamReader = New System.IO.StreamReader(dlg.FileName)

RichTextBox1.Text = sr.ReadToEnd()

sr.Close()

End If
Make sure that code is pasted below the Private Sub code, but above End Sub. If you didn't change the name of your RichTextBox it should work.
6
Now go back to the Form. Double click Save Document. The script editor should show up again. Do like the last one, except paste in this code:
Dim dlg As SaveFileDialog = New SaveFileDialog

dlg.Filter = "Text Files (*.txt) |*.txt"

dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal) ' This sets the intial path to 'My Documents'

If DialogResult.OK = dlg.ShowDialog Then

Dim sr As System.IO.StreamWriter = New System.IO.StreamWriter(dlg.FileName)

sr.Write(RichTextBox1.Text)

sr.Flush() ' Probably not needed, but will make sure that everything that's been streamed is written

sr.Close()

End If
7 Now, start debugging and try to open a .txt file, not a .rtf file!
Image
If you did everything as I said, you should have a working text editor!
Now finish it up by changing the Form's name and stuff.
DO NOT CHANGE THE NAME OF THE RICH TEXT BOX!!

Hope this tutorial is good! Afterall, its my first one! :D
[/img]

Posted: Thu Nov 17, 2005 11:15 pm
by BlairBitch
nice tut now what about spell chek for us noobs? great job glad people are still posting things on vb :D

Posted: Fri Nov 18, 2005 7:33 am
by superaison
ok i gotta fix 2 of your mistakes number one, opening:

this is the code u must put

Code: Select all

Dim dlg As OpenFileDialog = New OpenFileDialog

        dlg.Filter = "Text Files (*.txt) |*.txt"

        If Windows.Forms.DialogResult.OK = dlg.ShowDialog Then

            Dim sr As System.IO.StreamReader = New System.IO.StreamReader(dlg.FileName)

            RichTextBox1.Text = sr.ReadToEnd()

            sr.Close()

        End If
and saveing/closing

Code: Select all

  Dim dlg As SaveFileDialog = New SaveFileDialog

        dlg.Filter = "Text Files (*.txt) |*.txt"

        dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal) ' This sets the intial path to 'My Documents'

        If Windows.Forms.DialogResult.OK = dlg.ShowDialog Then

            Dim sr As System.IO.StreamWriter = New System.IO.StreamWriter(dlg.FileName)

            sr.Write(RichTextBox1.Text)

            sr.Flush() ' Probably not needed, but will make sure that everything that's been streamed is written

            sr.Close()

        End If

Posted: Fri Nov 18, 2005 7:50 am
by scubakobe
Hey you got a problem, those are exactly what I put in my tutorial. Are you trying to make me look bad by posting "mistakes" that arent mistakes?? :shock:

Posted: Fri Nov 18, 2005 8:20 am
by superaison
scubakobe wrote:Hey you got a problem, those are exactly what I put in my tutorial. Are you trying to make me look bad by posting "mistakes" that arent mistakes?? :shock:
hum, well when i put ir in i had to change some shit, i dont remember. hum ill look closer, i aint trying to make u look bad so u know

Posted: Fri Nov 18, 2005 8:24 am
by superaison
haahahaha lmao u changed your post, i can tell :P :P rofl i can tell from the times and shit dude, so u just spammed and flamed for no reason:P what a douche:P

Posted: Fri Nov 18, 2005 3:03 pm
by BEEF!!!
And you just double posted so you have nothing to yell at him for.

Posted: Fri Nov 18, 2005 3:05 pm
by Chromega
superaison wrote:what a douche:P
Fun Fact: douche is French for shower.

Posted: Fri Nov 18, 2005 3:12 pm
by Patrickssj6
And once again people got schooled by Chromega :wink:

Posted: Fri Nov 18, 2005 3:37 pm
by scubakobe
One thing in life that is hard to get over, is the fact that others put down a good deed. They twist it, scrape it, tear it until its useless. If everyone at halomods has an intention for this then no one here will accomplish anything. Its obvious thats happening right now, more questions being asked then answered. Some are n00b questions, and they are so easy to answer you guys just put down the person asking the question. One thing I have to say for all of you too good to care people is shut your mouth up if you have nothing good to say about a good deed.

Posted: Fri Nov 18, 2005 4:32 pm
by scubakobe
Chromega wrote:
superaison wrote:what a douche:P
Fun Fact: douche is French for shower.
lol, fun fact...good one chromega :D

(So since this is a tutorial, can it be stickied? :?: )

Posted: Fri Nov 18, 2005 4:37 pm
by superaison
omg some one wants be banned no time for my correctness

ok, he is trying to cover up by just cheating me out, when i clearly fixed his error inwhich if u see that he edited it and he edited his post ofter i posted and flamed me, so if u guys are blind then i will take pictures

Posted: Fri Nov 18, 2005 5:16 pm
by scubakobe
You are retarded, I never edited my original post.
Prove that I did something wrong by coming up with an error in my original...oh burned :lol:

Posted: Fri Nov 18, 2005 5:44 pm
by BEEF!!!
scubakobe wrote:You are retarded, I never edited my original post.
Prove that I did something wrong by coming up with an error in my original...oh burned :lol:
Wrong. You did and there's no point in hiding it:
Last edited by scubakobe on Fri Nov 18, 2005 10:54 am; edited 1 time in total
That is at the bottom of your post. Don't try to pass off that you didn't edit it.

Posted: Fri Nov 18, 2005 7:55 pm
by imgettionowned
OWNED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Posted: Fri Nov 18, 2005 10:27 pm
by scubakobe
Ok, I meant that I didnt edit the script, I admit that I edited the thing where I had a picture below "Hope this helps..", so I put it above it.
No big deal. The other person can't even prove it.
So what are you mods going to do? Keep allowing that person to try to find some mistake thats not even there, or delete his post and let people learn how to make a text editor. Thats I wanted, was to make a tutorial.
But nooooo...someone has to come and start making up mistakes, and not backing them up. Get a life.

So use this tutorial to learn how to make a text editor!

SO SHUT UP YOU LITTLE NOOB! :lol:

Posted: Fri Nov 18, 2005 10:29 pm
by scubakobe
scubakobe wrote:One thing in life that is hard to get over, is the fact that others put down a good deed. They twist it, scrape it, tear it until its useless. If everyone at halomods has an intention for this then no one here will accomplish anything. Its obvious thats happening right now, more questions being asked then answered. Some are n00b questions, and they are so easy to answer you guys just put down the person asking the question. One thing I have to say for all of you too good to care people is shut your mouth up if you have nothing good to say about a good deed.

Posted: Sat Nov 19, 2005 12:23 pm
by superaison
scubakobe wrote:Ok, I meant that I didnt edit the script, I admit that I edited the thing where I had a picture below "Hope this helps..", so I put it above it.
No big deal. The other person can't even prove it.
So what are you mods going to do? Keep allowing that person to try to find some mistake thats not even there, or delete his post and let people learn how to make a text editor. Thats I wanted, was to make a tutorial.
But nooooo...someone has to come and start making up mistakes, and not backing them up. Get a life.

So use this tutorial to learn how to make a text editor!

SO SHUT UP YOU LITTLE NOOB! :lol:
not so fast, i remember the mistake, ill repost what u had, oh and u need to stop, u are just trying to cover up, hum i think i should show them my pm's

Posted: Sat Nov 19, 2005 2:27 pm
by BEEF!!!
Ok, here we go.
1.) You people need to stop double posting!!!
2.) Bring this to PMs or AIM.
*lock*