Open File in ListBox
hola Hombres! =D
I need some help!! pls
My dream is code little App that do this simple things!:
-Open text File with different extensions (not binary file), recognize the "\r" "\n" values if exist! and print this text line per line in a ListBox!
-instead in another textbox i want able to put my text for replace string text in the single record of the ListBox
-Save file
i hope you help me and you understand my question cause i don't speak eng!!
regards
PS: sorry 4 ma bad eng!! :D
[561 byte] By [
eNdOVEiN] at [2007-11-11 7:36:02]

# 1 Re: Open File in ListBox
You can use VB's Open statement to open a file, and the Line Input statement to read it one line at a time. Use the ListBox's AddItem method to add each line to the ListBox, and the Replace function to replace one string with another. For more information on these statements and functions, consult VB's online help or search the Web. If you get stuck, feel free to post a followup question.
# 2 Re: Open File in ListBox
You can use VB's Open statement to open a file, and the Line Input statement to read it one line at a time. Use the ListBox's AddItem method to add each line to the ListBox, and the Replace function to replace one string with another. For more information on these statements and functions, consult VB's online help or search the Web. If you get stuck, feel free to post a followup question.
tnx!
# 3 Re: Open File in ListBox
I think u can add the file to the list.
but now u can't modify a line in the list.
first u have to select the line in the list,then the program will put the line in a text box --> 1
then u can modify and press a button to send modified text to the list --> 2
finally saving --> 3
Example will be as :
list name = list1
text name = text1
file path = [MyFile]
==============================================
1- In list1 click event add this code to put the line in text1
text1=list1.text
2- in sending text button add this code
a=list1.listindex
list1.removeitem a
list1.additem text1,a
3- In save command add this code
open [MyFile] For output as #1
for i=1 to list1.listcount
print list1.list(i-1)
next
close
==========================================
I typed this code from my brain so plz if any member found an error plz correct
(Sorry about my english)
MMA at 2007-11-11 17:28:44 >

# 4 Re: Open File in ListBox
Tnx MMA for u help me with this piece of code! :D
------------
2- in sending text button add this code
a=list1.listindex
list1.removeitem a
list1.additem text1,a
------------
i have change something and now work perfectly,:
starting your code you can just remove and then add new string
but if yuo send a new string without remove, you receive an error!!!
Private Sub Command1_Click()
Dim strtemp As String
Dim filename As String
Dim a As String
strtemp = Text1
'write new string if empty file <- this very necessary :D
a = List1
If a = "" Then
List1.AddItem Text1
Else
'replace selected string with my own
strtemp = List1.ListIndex
List1.RemoveItem strtemp
List1.AddItem Text1, strtemp
Close #1
End If
End Sub
tnx a lot!!!! :WAVE:
OK now i need some more help with "Serch Function"!!!! ;D