rattytatt50
Member
- Joined
- Oct 26, 2007
- Sythe Gold
- 0
- Messages
- 67
**********************
* Rattys Tutorials *
**********(c)*********
Save files:
You need a richtextbox, savefiledialogue in the dialogue section. Change the savefiledialogue to SaveFile for easy rememberings.
code:
The savefile.filename is "" because when user goes to save he wouldnt have a preset title.
SaveFile.Filter = "rich text format|*.rtf" means user can only save in .rtf format. (RTF is recommended because .txt will display the directory on every save) - NAME | *.FILE SUFFIX -
There is another way to save without a save dialogue. create a textbox, a button and a richtextbox.
the 'system.io.file.exists(file) = True' bit means that the directory/file already exists. So a message box pops up telling the user if they want to overwrite. This way though you can save in nearly every language. .HTML .PHP and so on...
The open file code:
Pretty much the same but have a file dialogue.
Aligning text. Left, right and center.
You need a richtext box and 3 buttons.
for the left code
for the center code
and for the right code...
Zoom factoring.
You need a richtextbox and 3 buttons (more if you wish)
zooming is complicated in some ways but its easy when you know the numbers back to front.
0.1 = 10%
0.25 = 25%
1 = 100%
10 = 1000%
You can only go from 0.1 to 63, so i think 6300% is big enough.
code for the buttons:
its easy as that.
REGIONS:
use
use any sort of code in there to shorten up and tidy your code. Its still there but in a collaspable bundle of text.
BOLD, ITALICS AND UNDERLINING:
you may want to use 'SelectedText' for this. Because it formats HILIGHTED text then. Not the whole textbox.
COPY, PASTING, CUTTING AND UNDOING
well its easy
UPPERCASE AND LOWER CASE
changes the hilighted text into upper case or lower case
and for the lowercase code
OPENING THE SAME FILE AGAIN
you cant just use me.show because it will get errored so....
Well thats all, ill add some more in a few days.
Please look at my text editor below - TextPad
http://www.2shared.com/file/2512867/bdfe3d1b/TEXTPAD.html
* Rattys Tutorials *
**********(c)*********
Save files:
You need a richtextbox, savefiledialogue in the dialogue section. Change the savefiledialogue to SaveFile for easy rememberings.
code:
Code:
SaveFile.FileName = ""
SaveFile.Filter = "Rich Text Format|*.rtf"
SaveFile.Title = "Save as..."
SaveFile.OverwritePrompt = True
If SaveFile.ShowDialog = Windows.Forms.DialogResult.OK Then
RichTextBox1.SaveFile(SaveFile.FileName)
End If
SaveFile.Filter = "rich text format|*.rtf" means user can only save in .rtf format. (RTF is recommended because .txt will display the directory on every save) - NAME | *.FILE SUFFIX -
There is another way to save without a save dialogue. create a textbox, a button and a richtextbox.
Code:
Dim FILE as String = textbox1.text
Dim msgResult as msgboxresult
If system.io.file.exists(file) = False then
Dim saveFile as new system.io.streamwriter
saveFile.write(richtextbox1.text)
saveFile.close
msgbox("Written")
Else If system.io.file.exists(file) = True then
messagebox.show("File already exists, overwrite?", "Overwrite", messageboxbuttons.yesno)
Else if msgResult = messagebox.yes then
saveFile.write(richtextbox1.text)
saveFile.close
msgbox("Written")
the 'system.io.file.exists(file) = True' bit means that the directory/file already exists. So a message box pops up telling the user if they want to overwrite. This way though you can save in nearly every language. .HTML .PHP and so on...
The open file code:
Pretty much the same but have a file dialogue.
Code:
OpenFile.FileName = ""
OpenFile.Filter = "Rich Text Format|*.rtf"
If OpenFile.ShowDialog = Windows.Forms.DialogResult.OK Then
RichTextBox1.LoadFile(OpenFile.FileName)
Aligning text. Left, right and center.
You need a richtext box and 3 buttons.
for the left code
Code:
Richtextbox1.selectionalignment = horizontalalignment.left
for the center code
Code:
Richtextbox1.selectionalignment = horizontalalignment.center
and for the right code...
Code:
Richtextbox1.selectionalignment = horizontalalignment.right
Zoom factoring.
You need a richtextbox and 3 buttons (more if you wish)
zooming is complicated in some ways but its easy when you know the numbers back to front.
0.1 = 10%
0.25 = 25%
1 = 100%
10 = 1000%
You can only go from 0.1 to 63, so i think 6300% is big enough.
code for the buttons:
Code:
richtextbox1.zoomfactor = "NUMBER HERE"
its easy as that.
REGIONS:
use
Code:
#region "NAME OF REGION GOES IN HERE"
#end region
use any sort of code in there to shorten up and tidy your code. Its still there but in a collaspable bundle of text.
BOLD, ITALICS AND UNDERLINING:
you may want to use 'SelectedText' for this. Because it formats HILIGHTED text then. Not the whole textbox.
Code:
dim font as font = richtextbox1.font
richtextbox1.font = new font(font.name, 8, fontstyle.[ITALIC, BOLD, UNDERLINE, REGULAR OR STRIKEOUT]
COPY, PASTING, CUTTING AND UNDOING
well its easy
Code:
richtextbox1.copy()
Code:
richtextbox1.paste()
Code:
richtextbox1.cut()
Code:
richtextbox1.undo()
UPPERCASE AND LOWER CASE
changes the hilighted text into upper case or lower case
Code:
dim upper as string = richtextbox1.selectedtext
richtextbox1.selectedtext = upper.toUpper
and for the lowercase code
Code:
dim lower as string = richtextbox1.selectedtext
richtextbox1.selectedtext = lower.toLower
OPENING THE SAME FILE AGAIN
you cant just use me.show because it will get errored so....
Code:
dim myfile as new form1
myfile.show()
Well thats all, ill add some more in a few days.
Please look at my text editor below - TextPad
http://www.2shared.com/file/2512867/bdfe3d1b/TEXTPAD.html

