View Single Post
 
Old 12-18-2014, 03:25 PM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

Not sure why your wanting to use a textbox to write to a file. You do not need it to do so.
Code:
Imports System.IO Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 'Add four sample items to a listbox. With ListBox1 .Items.AddRange(New String() {"Cat", "Rat", "Dog", "Zebra"}) End With End Sub Private Sub cmdWriteListbox_Click(sender As System.Object, e As System.EventArgs) Handles cmdWriteListbox.Click 'Write listbox contents to a file With ListBox1 Dim LinesOfText(.Items.Count - 1) As String .Items.CopyTo(LinesOfText, 0) File.WriteAllLines("C:\MyTextFile.txt", LinesOfText) End With End Sub Private Sub cmdClearListbox_Click(sender As System.Object, e As System.EventArgs) Handles cmdClearListbox.Click 'Clear listbox of items ListBox1.Items.Clear() End Sub Private Sub cmdReadListbox_Click(sender As System.Object, e As System.EventArgs) Handles cmdReadListbox.Click 'Read text from file and fill a listbox With ListBox1 Dim LinesOfText = File.ReadAllLines("C:\MyTextFile.txt") .Items.AddRange(LinesOfText) End With End Sub End Class
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote