Results 1 to 4 of 4

Thread: reading from a text file

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Location
    Mexico
    Posts
    16

    Smile reading from a text file

    I have a text file that contains 6 records per line. Each field is separated by a "!". I need to be able to read each line (record), set a variable to each field, and then insert a new reocrd into a sql database using the variables.

    I appreciate any help!

  2. #2
    Lively Member
    Join Date
    Feb 2001
    Location
    Fort Lauderdale, FL
    Posts
    98
    you can use instr() function to show you where each ! is.
    Then you can use the mid function to select all the text
    between the 2 instr() values.


    Hope this helps.

  3. #3
    New Member
    Join Date
    Aug 2001
    Location
    everywhere, yet nowhere.
    Posts
    12

    Unhappy

    I'm doing a similar thing to the above except my numbers are just separated by spaces. It's a list of Time and Latitude / Longitude for an earthquake program. I was wondering if anyone could give me a bit more detail on how to get the separate numbers into separate variables - like Latitude into the variable Lat etc.

  4. #4
    Lively Member
    Join Date
    Feb 2001
    Location
    Fort Lauderdale, FL
    Posts
    98
    Let's say your string is "59 137 2 18"
    Try this...
    dim sString as String
    dim sNumber1 as String
    dim sNumber2 as String

    sString = "59 137 2 18"
    sNumber1 = left$(sString, instr(sString," "))
    sString = right$(sString,len(sString)-len(sNumber1)+1)
    sNumber2 = Left$(sString,instr(sString," "))
    etc, etc

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