Results 1 to 10 of 10
  1. #1
    /b/oss's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Posts
    13,651
    Reputation
    795
    Thanks
    3,547

    Post [TUT]Open & Close Text

    How to open .txt files and how to save .txt files using textbox.

    1. Open Visual Basic 2008 > Windows Forms Application.
    2. Add 2 Buttons and 1 textbox (and opf and sfd)
    3. It should now look something like this.
    [IMG]https://i965.photobucke*****m/albums/ae133/MUSHIMOUSE/text.png[/IMG]
    4. Double click on button1 and add this code.
    [PHP]SaveFileDialog1.Filter = "text files (*.txt)| *.txt"
    SaveFileDialog1.ShowDialog()
    If SaveFileDialog1.FileName <> Nothing Then
    My.Computer.FileSystem.WriteAllText(SaveFileDialog 1.FileName, TextBox1.Text, False)
    End If[/PHP]
    5. Double click button2 and add this code.
    [PHP]OpenFileDialog1.Filter = "text files (*.txt)| *.txt"
    OpenFileDialog1.ShowDialog()
    Dim fname As String = OpenFileDialog1.FileName
    If System.IO.File.Exists(fname) Then
    Dim read As New System.IO.StreamReader(fname)
    TextBox1.Text = read.ReadToEnd
    read.Close()
    End If[/PHP]
    6. Ok now debug to see if it works.
    7. If it works then pat yourself on the back and serve yourself some ice tea because you just made a simple Open & Save .txt program:]

  2. The Following User Says Thank You to /b/oss For This Useful Post:

    highLIGHTED (06-10-2010)

  3. #2
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    Me.Text = System.IO.Path.GetFileNameWithoutExtension(Openfil edialog1.FileName)



  4. #3
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by m_t_h View Post
    5. Double click button2 and add this code.
    [PHP]OpenFileDialog1.Filter = "text files (*.txt)| *.txt"
    OpenFileDialog1.ShowDialog()
    Dim fname As String = OpenFileDialog1.FileName
    If System.IO.File.Exists(fname) Then
    Dim read As New System.IO.StreamReader(fname)
    TextBox1.Text = read.ReadToEnd
    read.Close()
    End If[/PHP]
    OpenFileDialog1.Filter = "text files (*.txt)| *.txt"
    If Not OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
    TextBox1.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1 .Filename)
    End If

    Quote Originally Posted by m_t_h View Post
    7. If it works then pat yourself on the back and serve yourself some ice tea because you just made a simple Open & Save .txt program:]
    Last edited by Hassan; 06-09-2010 at 05:01 AM.

  5. #4
    MvRouC12's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Location
    Stalking Choobs
    Posts
    1,690
    Reputation
    13
    Thanks
    246
    My Mood
    Amused
    Very very simple tut. Thanks for sharing anyways.

    [IMG]https://i986.photobucke*****m/albums/ae345/TripleSixPf/Okami-MvRouC12.jpg[/IMG]
    Quote Originally Posted by m_t_h View Post


    By stop playing AVA untill brasilian server comes.

    Do you guys really need to ruin EVERY game?
    [IMG]https://i175.photobucke*****m/albums/w148/Guitarman1157/dontforget.gif[/IMG]

  6. #5
    /b/oss's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Posts
    13,651
    Reputation
    795
    Thanks
    3,547
    Quote Originally Posted by FLAMESABER View Post
    xD you already did it :P

  7. #6
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    why is it always you posting this small stuff? =\
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  8. #7
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    This is not really a tutorial, you should have posted this in the snippet vault IMO.



  9. #8
    /b/oss's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Posts
    13,651
    Reputation
    795
    Thanks
    3,547
    Quote Originally Posted by Brinuz View Post
    why is it always you posting this small stuff? =\
    be happy -.-"

  10. #9
    Zoom's Avatar
    Join Date
    May 2009
    Gender
    male
    Location
    Your going on my 24/7 DDoS hit list.
    Posts
    8,552
    Reputation
    127
    Thanks
    5,970
    My Mood
    Happy
    Simple
    But good job.
    -Rest in peace leechers-

    Your PM box is 100% full.

  11. #10
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    Posted in snippet vault.

  12. The Following User Says Thank You to Lolland For This Useful Post:

    NextGen1 (06-09-2010)

Similar Threads

  1. [TuT] Open ur HDD
    By tuve2 in forum XBOX General Discussion
    Replies: 4
    Last Post: 06-02-2010, 07:42 AM
  2. [Tutorial]Open and Close cd tray
    By XxTylerxX in forum C# Programming
    Replies: 1
    Last Post: 05-17-2010, 05:15 PM
  3. [TUT] How to Print Text in Visual Basic
    By Mr. Jingles in forum Visual Basic Programming
    Replies: 0
    Last Post: 09-08-2009, 08:23 PM
  4. [TuT]Very Basic Broken Text
    By Dorado in forum Tutorials
    Replies: 16
    Last Post: 08-20-2009, 07:14 PM
  5. [TuT]Very Basic Broken Text
    By Dorado in forum Help & Requests
    Replies: 2
    Last Post: 05-28-2009, 09:52 PM