Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Pull infromation from a txt file

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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…
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…
Suggested Courses

722 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