Save textbox and listbox in one file (VB3)
In my programm there's listlox (List1), which I can save in
a Text-File. Now I want to add a textbox, in which the user
can write his name or something else. Now I want, that
this textbox is the first line of the textfile and the following lines are from the listbox.
1. How is the code for saving it ?
2. How must I write the code, that the first line gets
into a textbox and the rest into the listbox when I open the
file ?
For this programm I use VB 3.0 (but normally this isn't a problem)
Thanks for some advice, Matt ;)
[Edited by Matt-D on 03-23-2000 at 10:45 AM]
Re: Save Textbox and Listbox in one file (VB3)
first put the text file into the listbox
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
OpenFileDialog1.Filter = "Text Files (*.TXT)|*.TXT" 'looks for files ending in TXT
OpenFileDialog1.ShowDialog() 'Common dialog
If OpenFileDialog1.FileName <> "" Then 'Is there a real filename
FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input) 'if so open the file for input
Call ReadFile() 'a subroutine to read the file
End If
On Error Resume Next
FileClose()
End Sub
-------------------
Sub ReadFile()
While Not EOF(1)
ListBox1.Items.Add(LineInput(1)) 'text items in file go into listbox
End While
End Sub
--------------------------------
hope this helps
Re: Save textbox and listbox in one file (VB3)
Quote:
Originally Posted by Matt-D
In my programm there's listlox (List1), which I can save in
a Text-File. Now I want to add a textbox, in which the user
can write his name or something else. Now I want, that
this textbox is the first line of the textfile and the following lines are from the listbox.
1. How is the code for saving it ?
2. How must I write the code, that the first line gets
into a textbox and the rest into the listbox when I open the
file ?
For this programm I use VB 3.0 (but normally this isn't a problem)
Well the procedure is the same whether is VB3/4/5 or 6. As explained by OneSource. ;)
Re: Save Textbox and Listbox in one file (VB3)
It's almost 9 years later - I really hope he doesn't actually care about this any more. ;)