Solved

Pull infromation from a txt file

Posted on 2003-11-18
3
261 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

758 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

24 Experts available now in Live!

Get 1:1 Help Now