VB6: Reading from specific line in a txt file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Einvalt
    New Member
    • Feb 2006
    • 1

    VB6: Reading from specific line in a txt file

    My program keeps a text file list of co-ordinates, for example:

    3,5
    2,7
    12,9
    5,6
    ... and so on, indefinitely.

    How do I read the values from the nth line into variables X,Y - say if I specific the 3rd line, then X=12 and Y=9?

    Also, how can I search the text file to check if a specific co-ordinate pair is already in the list?
  • haydee

    #2
    Hallo,

    dou you mind if you tell me how did you read the specific line number you wanted? thanks,

    haydee


    Originally posted by Einvalt
    My program keeps a text file list of co-ordinates, for example:

    3,5
    2,7
    12,9
    5,6
    ... and so on, indefinitely.

    How do I read the values from the nth line into variables X,Y - say if I specific the 3rd line, then X=12 and Y=9?

    Also, how can I search the text file to check if a specific co-ordinate pair is already in the list?

    Comment

    • sashi
      Recognized Expert Top Contributor
      • Jun 2006
      • 1749

      #3
      Hi there,

      i would suggest you using .ini file instead .txt file.. ini files are more flexible..

      you can make use of some simple API.. see below..

      Code:
      Sub WriteINIStringVirtual(Section, KeyName, Value, FileName)
        WriteINIString Section, KeyName, Value, _
          Server.MapPath(FileName)
      End Sub
      
      Function GetINIStringVirtual(Section, KeyName, Default, FileName)
        GetINIStringVirtual = GetINIString(Section, KeyName, Default, _
          Server.MapPath(FileName))
      End Function
      usage..
      Code:
      WriteINIString "xxx"xxx", "xxx", "filename.ini"

      Comment

      Working...