Results 1 to 2 of 2

Thread: Reading Tab Delimited File Using 'Input' Function

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    70

    Cool

    Using VB6 Pro.

    I am importing data to an Access database from a text file. How do I skip the first 4 or so lines (File Header)?.

    Also using the 'Split' function to split each line into fields so I can add to appropriate field in Access table.
    eg Split(expression[, delimiter[, count[, compare]]])
    How to I define the delimiter as a tab?

    Any help would be appreciated

    Cheers


  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    here is some ADO code that connects to a CSV file, it might make your life easier:
    Code:
    'Uses ADO 2.1/5
    
        Dim cn As Connection
        Dim rs As Recordset
        
        Set cn = New Connection
        Set rs = New Recordset
        
        'open connection to folder that contains the CSV file
        cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties=Text;"
        
        'open the file
        rs.Open "select * from test.csv", cn
        
        'we have data
        MsgBox rs.Fields(1).Value
    You can use vbTab as the delimiter keyword

    If you are using Input statements to read your data, you could just use 4 Line Input statements to skip the first 4 lines

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width