Results 1 to 6 of 6
  1. #1
    GER-Domi.'s Avatar
    Join Date
    May 2010
    Gender
    male
    Posts
    277
    Reputation
    15
    Thanks
    823
    My Mood
    Cool

    need help!? read and write (txt)

    hi i have a litte problem xD

    i like to write something in a txt file.. for read i have this code:
    Code:
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim Linie() As String = IO.File.ReadAllLines("C:\lol.txt")
    
            TextBox1.Text = Linie(0) & vbNewLine
            TextBox2.Text = Linie(1) & vbNewLine
       
        End Sub
    End Class
    someone know the code for write? can someone show me please!?

  2. #2
    Beaverman's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Posts
    53
    Reputation
    20
    Thanks
    16
    Code:
                
    Dim oWrite As New System.IO.StreamWriter(".\serial.txt")
    oWrite.WriteLine("pizzaman")
    oWrite.Flush()
    oWrite.Close()
    there ya go

  3. The Following User Says Thank You to Beaverman For This Useful Post:

    GER-Domi. (09-10-2010)

  4. #3
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    Not his code though.

  5. #4
    Imported's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    142
    Reputation
    27
    Thanks
    47
    My Mood
    Relaxed
    Always use "using" if you can, it's much cleaner.

    [php]
    Using sWrite As New IO.StreamWriter(C:\Example\Here.txt")

    sWrite.WriteLine(TextBox1.Text)
    sWrite.WriteLine(TextBox2.Text)

    End Using
    [/php]
    TROLOLOLOLO


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

    GER-Domi. (09-10-2010)

  7. #5
    GER-Domi.'s Avatar
    Join Date
    May 2010
    Gender
    male
    Posts
    277
    Reputation
    15
    Thanks
    823
    My Mood
    Cool
    Ok thx i will try

  8. #6
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    Using sWrite As New IO.StreamWriter(C:\Example\Here.txt", append as boolean)


    End Using

    [php]Using sWrite As New IO.StreamWriter(C:\Example\Here.txt",true) 'this will APPEND the text

    end using[/php]

    [php]Using sWrite As New IO.StreamWriter(C:\Example\Here.txt") 'this is just going to overwrite it, why not ,false? Because it is false by default.

    end using[/php]

    [php]Using sWrite As New IO.StreamWriter(C:\Example\Here.txt")

    for each line as string in listbox1.items
    sWrite.write(line & vbnewline)
    next[/php]

    [php]
    dim line as string
    Using sRead As New IO.StreamReader(C:\Example\Here.txt")
    while not sRead.EndOfStream
    line = sRead.Readline
    if line <> "" then
    listbox1.items.add(line)
    end if
    end while
    end using[/php]



Similar Threads

  1. [TUT]How to read and write to a text file
    By XORxHACK in forum Java
    Replies: 18
    Last Post: 02-26-2010, 04:41 PM
  2. Need help reading Korean
    By zxcdserf in forum Suggestions, Requests & General Help
    Replies: 2
    Last Post: 02-24-2010, 07:14 PM
  3. [Help]Reading and Writing to .txt files on the internet
    By treeham in forum Visual Basic Programming
    Replies: 6
    Last Post: 01-30-2010, 01:07 AM
  4. [Tutorial/Snippet][VB6] Reading and writing INI Files
    By That0n3Guy in forum Visual Basic Programming
    Replies: 6
    Last Post: 10-26-2009, 05:31 PM
  5. Need Help? READ
    By carbon23 in forum Combat Arms Hacks & Cheats
    Replies: 9
    Last Post: 12-27-2008, 10:12 PM