CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2002
    Posts
    46

    input, "," as delimiter

    Im reading a text file, line by line i want to change a few lines of the entire file, and then write it back to the file with my new data, in parts of it, but the text file contains "," 's and it for some reason causes it break the line

    this is the file, it should be on one line

    reading it brings it in as

    this is the file
    it should be on one line

    the comma isnt read,

    im using the input statement

    Dim path As String
    Dim dat, rec As String
    path = localdir + name
    Open path For Input As #1

    Dim c, w As String
    Dim i As Integer
    Dim line As Integer

    Do While Not EOF(1)
    line = line + 1
    Input #1, dat
    Debug.Print dat
    Do While i < Len(dat)
    i = i + 1
    c = Mid(dat, i, 1)
    w = Mid(dat, i, 5)
    Loop
    i = 0
    Loop

    Close #1

  2. #2
    Join Date
    Aug 2001
    Posts
    1,447
    well, gee, do you reckon it could be because you specifically TOLD it to read in comma-delimited fashion?

    Look in the on-line help at the functions:
    Unlike the Input # statement, the Input function returns all of the characters it reads, including commas, carriage returns, linefeeds, quotation marks, and leading spaces.
    '
    '*****************************
    Moderators are warning you, Phinds!
    was it so difficult to write it like it is
    now?
    Cesare I.
    '*****************************
    Last edited by Cimperiali; November 4th, 2002 at 02:50 AM.
    phinds
    vs2008, 3.5SP1 Version 9.0.21022.8 RTM

  3. #3
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210
    Use the LINE INPUT statement instead. Here is a quote from the Help file
    Code:
    The Line Input # statement syntax has these parts:
    
    Part Description 
    filenumber Required. Any valid file number. 
    varname Required. Valid Variant or String variable name. 
    
    
    Remarks
    
    Data read with Line Input # is usually written from a file with 
    Print #.
    
    
    The Line Input # statement reads from a file one character at a 
    time until it encounters a carriage return (Chr(13)) or carriage 
    return–linefeed (Chr(13) + Chr(10)) sequence. Carriage return–linefeed sequences 
    are skipped rather than appended to the 
    character string.

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

Featured