Results 1 to 3 of 3

Thread: using the input command, but ignoring commas

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Posts
    81

    using the input command, but ignoring commas

    i have a cfg file that i need to read, but ive come across a problem. i need to read it a line at a time, but the lines may have commas in them. i tryed to just use the input command, but it seperated what it was reading in by the commas.

    for example, this might be the first line of the text file

    i want to input that into a variable, but right now i can only figure out how to read the "for example" and " this might be the first line of the text file" seperatly, since they are seperated by a comma.

    i didnt make the cfg file, so i have to read it as is. any help is appreciated

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: using the input command, but ignoring commas

    Well, I'm not shur about how to read a single line at a time but, you could use an alternative; read the whole fine inot an array and then opperate functions using the array

    VB Code:
    1. Dim intFree As Integer
    2. Dim strReadText As String
    3. Dim strTextLines() As String
    4. intFree = FreeFile
    5.  
    6. Open "C:\SomeFile.cfg" For Binary Access Read As #intFree
    7.     strReadText = Space$(LOF(intFree))
    8.     Get #intFree, , strReadText
    9. Close #intFree
    10.  
    11. ' Create array of text lines from the file...
    12. strTextLines = Split(strReadText, vbNewLine)
    13.  
    14. MsgBox strTextLines(0) ' First line...
    15. MsgBox strTextLines(1) ' Second line...

    Is an example I posted earlier today

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  3. #3
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016

    Re: using the input command, but ignoring commas

    instead of using Input, use Line Input.

    casey.

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