Results 1 to 8 of 8
  1. #1
    Shark23's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Kansas
    Posts
    424
    Reputation
    10
    Thanks
    55
    My Mood
    Cool

    [Help]Save Text[Solved]

    Alright, so I'm trying to save some entered text to my desktop in the C drive. I have
    Code:
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
            My.Computer.FileSystem.WriteAllText("C:/" & "\keys.txt", Text, True)
        End Sub
    but that isn't working. It has an empty text document named keys. Any ideas?
    Assembly Programmer

  2. #2
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Save TextBox.text as .Txt File

    [php]
    Imports System.IO
    [/php]

    Then Button click event (or whereever)

    [php]
    System.IO.File.WriteAllText("C:\keys.txt",TextBox1 .Text)
    [/php]

    or

    [php]
    Dim Tfile1 As String = "C:\keys.txt"
    IO.File.WriteAllText(Tfile, TextBox1.Text)
    [/php]

    If you want to save to your desktop, use SpecialFolderpath


    [php]
    Dim Deskloc As String
    Deskloc = Environment.SpecialFolder.Desktop


    Dim Tfile As String = "Deskloc" & "keys.txt"
    IO.File.WriteAllText(Tfile, TextBox1.Text)
    [/php]

    Hope this helps

    Last edited by NextGen1; 04-06-2010 at 09:29 PM.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  3. #3
    zmansquared's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    Kickin it at Microsoft
    Posts
    2,086
    Reputation
    36
    Thanks
    221
    My Mood
    Cheerful
    i want to answer these so bad, but my vb is still craped up
    Need Help With Coding or Something??? MSN me
    zmansquared@hotmail.com


    I am the one and only Microsoft Fag!!!

    Quote:
    Originally Posted by Arhk
    All games should be hacked, if we don't do it someone else will. Hackers force the progress, of better programming methods.
    ~


    Take this Pic everyone!



    next-

  4. #4
    Shark23's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Kansas
    Posts
    424
    Reputation
    10
    Thanks
    55
    My Mood
    Cool
    It's still just having a blank text file named keys.
    Assembly Programmer

  5. #5
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    "C:/" & "\keys.txt" = C:/\keys.txt

    how should that work o_O?

    -------------------------------

    Sorry nextgen, but I have to correct you


    Quote Originally Posted by Nextgen1
    If you want to save to your desktop, use SpecialFolderpath

    Code:
     Dim Deskloc As String
            Deskloc = Environment.SpecialFolder.Desktop
    
    
            Dim Tfile As String = "Deskloc" & "keys.txt"
            IO.File.WriteAllText(Tfile, TextBox1.Text)
    Deskloc will result as "0"

    The actual code to get the desktop folder path is the following

    Code:
    Dim Deskloc As String
            Deskloc = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    
    
            Dim Tfile As String = "Deskloc" & "keys.txt"
            IO.File.WriteAllText(Tfile, TextBox1.Text)


    ------------------------------------------------------------

    If that's not working for you try the following:


    Code:
    dim streami as streamwriter
    
    streami = New StreamWriter("C:\test.txt")
       streami.Write(Textbox1.text)
       streami.Close()



  6. The Following User Says Thank You to Blubb1337 For This Useful Post:

    MJLover (04-07-2010)

  7. #6
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    I did it off top of head, I don't use special folders often cause there is no reason for me to, But in either case, thanks for the 'Correction"


     


     


     



    The Most complete application MPGH will ever offer - 68%




  8. #7
    ftslynx's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    42
    Reputation
    12
    Thanks
    14
    hmmm if your doing it from with in VB then....

    uder public at the top
    Code:
    Dim var As New System.IO.StreamWriter("\MyText.txt", True)
    make a button,
    Code:
    var.WriteLine()
            var.WriteLine("Name: "& textbox1.text)
    var.close()
    textbox1 being the box were they placed there name or something...

    hope you can use this in some waty...

  9. #8
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    A. already answered and Solved
    B. Read the rules of this section (and Mpgh) no bumping topics over 7 days

    - I am not going to close this but it is marked solved, Do Not Post


     


     


     



    The Most complete application MPGH will ever offer - 68%




Similar Threads

  1. [Help]Saving ListView[Solved]
    By Lyoto Machida in forum Visual Basic Programming
    Replies: 19
    Last Post: 02-11-2011, 08:33 PM
  2. [Help]Rich Text[Solved]
    By mo3ad001 in forum Visual Basic Programming
    Replies: 7
    Last Post: 06-16-2010, 03:16 PM
  3. [Help]Saving settings[Solved]
    By Jason in forum Visual Basic Programming
    Replies: 36
    Last Post: 04-27-2010, 11:34 AM
  4. [Help]Save Text to Desktop[Solved]
    By ppl2pass in forum Visual Basic Programming
    Replies: 8
    Last Post: 03-16-2010, 08:45 AM
  5. [Help]Basic Text Box[Solved]
    By FlashDrive in forum Visual Basic Programming
    Replies: 3
    Last Post: 03-06-2010, 10:54 PM