Results 1 to 3 of 3

Thread: Reading from file to listview...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    Texas
    Posts
    140

    Reading from file to listview...

    Public Sub ReadWebLog()
    Dim intFNum As Integer
    Dim strRData As String
    Dim lstItem As ListItem
    Dim tdDate As Date
    Dim tdTime As Date
    Dim strWebsite As String
    Dim blnBlocked As Boolean

    intFNum = FreeFile

    Open (App.Path & "\WebLog.dat") For Input As #intFNum

    Do Until EOF(intFNum)

    Input #intFNum, tdDate, tdTime, strWebsite, blnBlocked

    Set lstitm = frmWebsiteLog.lstvWebLog.Add(, , tdDate)
    lstitm.ListSubLists(1).Text = tdTime
    lstitm.ListSubLists(2).Text = strWebsite
    lstitm.ListSubLists(3).Text = blnBlocked
    Loop


    Close #intFNum
    End Sub

    This code does not read from a comma-delimited file. I want to read this data into a listview control. It tells me .Add is not a method or anything, I don't know how to add this data to a litview contro. Can anyone help?!

  2. #2
    Hyperactive Member
    Join Date
    Feb 2001
    Location
    Belgium/Antwerp
    Posts
    275

    Cool

    Hi there,

    This is the edited code for your app, i 've tested it and it works fine.


    Public Sub ReadWebLog()
    Dim intFNum As Integer
    Dim strRData As String
    Dim lstItem As ListItem
    Dim tdDate As Date
    Dim tdTime As Date
    Dim strWebsite As String
    Dim blnBlocked As Boolean
    Dim i As Long

    intFNum = FreeFile

    Open (App.Path & "\WebLog.dat") For Input As #intFNum

    Do Until EOF(intFNum)

    Input #intFNum, tdDate, tdTime, strWebsite, blnBlocked
    i = i + 1
    Set lstItem = Me.lstvWebLog.ListItems.Add(, , tdDate)
    Me.lstvWebLog.ListItems.Item(i).SubItems(1) = tdTime
    Me.lstvWebLog.ListItems.Item(i).SubItems(2) = strWebsite
    Me.lstvWebLog.ListItems.Item(i).SubItems(3) = blnBlocked

    Loop


    Close #intFNum
    End Sub

    On your form there must be a listview with four columns and the view property must be set on 'lvwReport'

    If you have problems executing this code, please let me know, then I ll send you the VB project.

    Kind regards, Luc

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    Texas
    Posts
    140
    Thanks much, I'll try that when I get home.

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