Been Awhile...In Need of Help Once More!
Hey everyone,
it sure has been sometime since I've been on this site, says my last visit was "Jul 25th, 2007"...Anyway, I had an issue, I was wondering if someone can toss me a code for loading a simple text file into a ListView1. I'd appreciate it, and will send thanks. Thanks in advanced. :thumb:
Re: Been Awhile...In Need of Help Once More!
Code depends on how file is structured. Can you post any samples?
Re: Been Awhile...In Need of Help Once More!
Uh, like this?
Code:
Option Explicit
Private Sub Command1_Click()
Dim L As String
Open "z.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, L
List1.AddItem L
Loop
Close #1
End Sub
Mac
Re: Been Awhile...In Need of Help Once More!
Don't rush into the answers - you don't know what the file looks like... Besides, he said "ListView1" not Listbox. ;)
Re: Been Awhile...In Need of Help Once More!
Quote:
Originally Posted by RhinoBull
Don't rush into the answers - you don't know what the file looks like... Besides, he said "ListView1" not Listbox. ;)
Uh, what is "ListView1"?
Mac
Re: Been Awhile...In Need of Help Once More!
Quote:
Originally Posted by Mr.Mac
Uh, what is "ListView1"?
Mac
ListView is a member of MSCommon Controls 6.0, found on the Components tab.
Re: Been Awhile...In Need of Help Once More!
CdDrive is correct, but I applaud the effort in coding that part out for me. Rhino Bull, I dont have any code right now, I'm just attempting to make it to where I click command1, and I'm presented where I can navigate my files to the .txt file to load into the list.
Re: Been Awhile...In Need of Help Once More!
Rhino isn't asking for the source code. He's asking for sample data... the data in the text file or whats going to be transferred to the listview, to see if its columnar data and if so what's the delimiter.
Re: Been Awhile...In Need of Help Once More!
Well my initial plan with this was to have the user press a button to load a list of e-mails into the ListView1
Re: Been Awhile...In Need of Help Once More!
Quote:
Originally Posted by vbnewbie2007
Well my initial plan with this was to have the user press a button to load a list of e-mails into the ListView1
Again, what's the content of the textfile? Is it single column, vbCrLf delimited data, e.g.
[email protected]
[email protected]
[email protected]
Or is it a comma-separated (or comma delimited) values file?
[email protected], "My Name is abc", "Age 20"
[email protected], "My Name is def", "Age 21"
[email protected], "My Name is ghi", "Age 22"
And lastly, for multi-column data which columns will be transferred to listview? All of them?
You are not answering the questions correctly which is just prolonging the discussion.
Re: Been Awhile...In Need of Help Once More!
Quote:
Originally Posted by leinad31
You are not answering the questions correctly which is just prolonging the discussion.
Indeed... so I will try to ask once more:
CAN YOU POST SOME SAMPLE DATA THAT IS (OR WILL BE) IN YOUR FILE THAT YOU'RE PLANNING ON LOADING INTO YOUR LISTVIEW CONRTOL?
Thank you.
Re: Been Awhile...In Need of Help Once More!
'Again, what's the content of the textfile? Is it single column, vbCrLf delimited data, e.g.
[email protected]
[email protected]
[email protected]'
it is single column, like how it was posted above.
Re: Been Awhile...In Need of Help Once More!
You can use code in post #3 or the following
Code:
Dim i As Long
Dim intFF As Integer
Dim arrLines() As String
intFF = FreeFile
Open "z.txt" For Input As #intFF
arrLines = Split(Input(LOF(intFF), #intFF) ,vbCrLf)
Close #intFF
For i = 0 To Ubound(arrLines)
'add to listview code goes here
Next