Rattys Tutorials

Discussion in 'Programming General' started by rattytatt50, Nov 18, 2007.

Rattys Tutorials
  1. Unread #1 - Nov 18, 2007 at 3:36 PM
  2. rattytatt50
    Joined:
    Oct 26, 2007
    Posts:
    67
    Referrals:
    0
    Sythe Gold:
    0

    rattytatt50 Member

    Rattys Tutorials

    **********************
    * 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
    
    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.

    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
     
  3. Unread #2 - Nov 19, 2007 at 2:14 PM
  4. skate4lifee
    Joined:
    Jul 22, 2007
    Posts:
    108
    Referrals:
    1
    Sythe Gold:
    0

    skate4lifee Active Member

    Rattys Tutorials

    what is the significance of this?
     
  5. Unread #3 - Nov 20, 2007 at 11:17 AM
  6. rattytatt50
    Joined:
    Oct 26, 2007
    Posts:
    67
    Referrals:
    0
    Sythe Gold:
    0

    rattytatt50 Member

    Rattys Tutorials

    wat du mean?
     
  7. Unread #4 - Nov 20, 2007 at 11:19 AM
  8. rattytatt50
    Joined:
    Oct 26, 2007
    Posts:
    67
    Referrals:
    0
    Sythe Gold:
    0

    rattytatt50 Member

    Rattys Tutorials

    u cant open the same file as your in. Nothing will happen
     
  9. Unread #5 - Nov 20, 2007 at 2:47 PM
  10. skate4lifee
    Joined:
    Jul 22, 2007
    Posts:
    108
    Referrals:
    1
    Sythe Gold:
    0

    skate4lifee Active Member

    Rattys Tutorials

    i'm asking, why would you want to open the same file twice? give me a real life example where i would use this.
     
  11. Unread #6 - Nov 21, 2007 at 11:19 AM
  12. rattytatt50
    Joined:
    Oct 26, 2007
    Posts:
    67
    Referrals:
    0
    Sythe Gold:
    0

    rattytatt50 Member

    Rattys Tutorials

    ms word. Ohwell, its there.
     
< Progress Bar Help | RS world map??? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site