Solved

Pull infromation from a txt file

Posted on 2003-11-18
3
264 Views
Last Modified: 2010-05-18
Ok so I have the following script to pull information from a txt document, so I need to add another column to the information that is pulled.  However when I add another line to the code to try to add to the addtional column I keep getting errors.  So I must not have the script correct, thanks!

--------  Working Code  -------

    ' Declare variables
    Dim X1, X2, x3, x4 As String
    Dim i, xfile
    Dim NewItem As ListItem

    '  Set histroy file location
    xfile = "C:\Progra~1\Reflec~1\User\History.txt"
    ' Open histroy file for reading
    Open xfile For Input As #1

    'Set start value for list index
    i = 1

    ' Retrieve each record in history file until the end of file
    Do While Not EOF(1)
        ' Set date into columns for reading
        Input #1, X1, X2, x3, x4
       
        X1 = FormatDateTime(X1, 4)

        ' Add items to listview
        Set NewItem = lsvHis.ListItems.Add(, , (X1))
        NewItem.SubItems(1) = X2
        NewItem.SubItems(2) = x3
        NewItem.SubItems(3) = x4        

        ' Removes first line in text box from history ListView
        If lsvHis.ListItems.item(1) = "00:00" Then
            lsvHis.ListItems.Remove (1)
        End If

        ' Set number of records to textbox visible to reps
        txtNumber.Value = i - 1

        ' Set new value for list index before looping
        i = i + 1
    ' Loop for next record
    Loop
    ' Close History file
    Close #1

End Sub

--------  Break  --------

Here is what I have put togther to try to add another line.....

-------  Broke Code  --------

    ' Declare variables
    Dim X1, X2, x3, x4, x5 As String
    Dim i, xfile
    Dim NewItem As ListItem

    '  Set histroy file location
    xfile = "C:\Progra~1\Reflec~1\User\History.txt"
    ' Open histroy file for reading
    Open xfile For Input As #1

    'Set start value for list index
    i = 1

    ' Retrieve each record in history file until the end of file
    Do While Not EOF(1)
        ' Set date into columns for reading
        Input #1, X1, X2, x3, x4, x5
       
        X1 = FormatDateTime(X1, 4)

        ' Add items to listview
        Set NewItem = lsvHis.ListItems.Add(, , (X1))
        NewItem.SubItems(1) = X2
        NewItem.SubItems(2) = x3
        NewItem.SubItems(3) = x4
        NewItem.SubItems(4) = x5
       

        ' Removes first line in text box from history ListView
        If lsvHis.ListItems.item(1) = "00:00" Then
            lsvHis.ListItems.Remove (1)
        End If

        ' Set number of records to textbox visible to reps
        txtNumber.Value = i - 1

        ' Set new value for list index before looping
        i = i + 1
    ' Loop for next record
    Loop
    ' Close History file
    Close #1

End Sub
--------  Break  --------
0
Comment
Question by:gideonn
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 500 total points
ID: 9773736
Have you right clicked the Listview and added another column under the Column Headers Tab?
0
 
LVL 1

Author Comment

by:gideonn
ID: 9773871
Thanks I looked in there, but I missed that.  Thanks!
0
 
LVL 1

Author Comment

by:gideonn
ID: 9773872
Thanks I looked in there, but I missed that.  Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now