Solved

Pull infromation from a txt file

Posted on 2003-11-18
3
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month4 days, 13 hours left to enroll

635 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