Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editing a list box

Status
Not open for further replies.

jray2003

Programmer
Aug 12, 2003
253
US
I have read a text file into a list box but is there a way to edit the information? Maybe I went the wrong direction but I thought the list box would have been the best way to go.

What I do is Read in a file.
Edit the file
Save the file

So maybe a text box would have been better.

Thanks

Jim
 
Hmmm... You need to be more specific, a lot more!
Who is editing the items in the listbox you through code? Or the user?
If it’s the user I recommend using a combobox and a button.

If you are editing the data through code which I suspect than after the items are in the list do something lik.

Private Sub Command1_Click()
Dim I as integer
For i = 0 To List1.ListCount
List1.List(i) = List1.List(i) & "Add This"
Next i
End Sub

if that doesnt work for you give us some more info...
 
Excellent, just recently I completed a program that does exactly what it sounds like you're doing. It had to do with storing names of movies in a listbox and saving them to text file, closing the program, reopening it, then load the list from the text file back to listbox.

Code:

Private Sub loadCmd_Click()
Dim mov() As String
Dim m As Integer
Dim i As Integer
ReDim mov(0)

Dim line_count
Dim myFile
myFile = Dir("mov.lst")

If myFile = "" Then
MsgBox "File 'mov.lst' does not exist."
Else
Open "mov.lst" For Input As #1
Do While Not EOF(1)
Line Input #1, mov(line_count)
List1.AddItem mov(line_count)
line_count = line_count + 1
ReDim Preserve mov(line_count)
Loop
Close #1
End If

If List1.ListCount = 0 Then
MsgBox "0 movies are in the list."
ElseIf List1.ListCount = 1 Then
MsgBox "1 movie is in the list."
Else
MsgBox line_count & " movie names loaded successfully."
End If

Close #1

End Sub


I'm currently getting people to test my program on various OS platforms for compatibility testing.
 
Outstanding and yes that is what I wanted to do...

Thank again.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top