Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Pull infromation from a txt file

Posted on 2003-11-18
3
Medium Priority
?
272 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Suggested Courses

876 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