Results 1 to 2 of 2

Thread: Input from files column number

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Input from files column number

    I would like to do like this, If the files have four column from files, then it read the the line header from column 2 untill four.. How to do that? I have files some time have 3 column and four column. By default I want the program read the X,Y,Z value only.

    Code:
      Open txtDir For Input As #12
       
        n = 0
    
        'Read the file header first
        Line Input #12, XYZ
    '    Print #13, "X", "Y", "Z"
        While Not EOF(12)
    
            Input #12, Point.x_out, Point.y_out, Point.z_out
                 n = n + 1 'Record counter
    
        Wend

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Input from files column number

    I'd think you could use Line Input in the loop, rather than Input, and then Split
    Code:
    Dim strData() As String
    '
    '
    Line Input #12, strInput
    strData = Split(strInput, ",") ' assumes comma delimited data
    Point.x_out = Val(strData(0)
    Point.y_out = Val(strData(1)
    Point.z_out = Val(strData(2)

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