Results 1 to 13 of 13

Thread: Been Awhile...In Need of Help Once More!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    79

    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.

  2. #2

  3. #3
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    Washington DC
    Posts
    314

    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

  4. #4

  5. #5
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    Washington DC
    Posts
    314

    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

  6. #6
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    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.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    79

    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.

  8. #8
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    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.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    79

    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

  10. #10
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    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.
    Last edited by leinad31; Feb 26th, 2008 at 07:45 PM.

  11. #11
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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.

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Jun 2007
    Posts
    79

    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.

  13. #13
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width