|
|
|
|
![]() ![]() |
Feb 14 2007, 03:50 AM
Post
#1
|
|
|
Newbie ![]() Group: Members Posts: 1 Joined: 14-February 07 Member No.: 38,683 |
Hello, I have a project that I am doing. I have a list box that you can enter data in, and I need it to have the ability to save that list into a text file (Names.txt). The txt file should have each entry on it's own line. Any help would be appreciated.
|
|
|
|
Feb 17 2007, 05:59 PM
Post
#2
|
|
|
Neurotical Squirrel ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 585 Joined: 4-November 04 From: Novi Sad, Vojvodina Member No.: 2,127 |
I'm not sure about Vb.Net, I haven't touched it in couple of years, but I can give you code, how it would look in VB6, and you can go from there:
CODE Dim i As Long Open "Names.txt" For Output As #1 For i = 0 To List1.ListCount - 1 Print #1, List1.List(i) Next i Close #1 And that's it... I believe it should be fairly simple in Vb.Net too... Probably very similar... |
|
|
|
Mar 26 2007, 10:23 AM
Post
#3
|
|
|
Neurotical Squirrel ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 585 Joined: 4-November 04 From: Novi Sad, Vojvodina Member No.: 2,127 |
OK, I'm sure you already found what you were looking for, but I'll post an example code, of how to write text files in VB.NET... Maybe someone in the future would find it usefull:
CODE Imports System Imports System.IO Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f As StreamWriter, i As Long, obj As Object For i = 1 To 10 ListBox1.Items.Add("Item " & i.ToString) Next i f = New StreamWriter("C:\Test.txt") For i = 0 To ListBox1.Items.Count - 1 f.WriteLine(ListBox1.Items.Item(i).ToString) Next i f.Close() End Sub End Class That's the full working code, just copy and paste it in your project, and voila... Hope it helped a bit |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 25th July 2008 - 10:25 AM |