Results 1 to 4 of 4

Thread: Count the number of tabs "\n"

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    4

    Count the number of tabs "\n"

    Any idea how I can count the number of tabs embedded at the beginning of a line in a text file when im parsing the file.

    thanks.

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Count the number of tabs "\n"

    Are you looking for the string "\n" or ControlChars.Lf

    followed by a count of ControlChars.Tab
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    4

    Re: Count the number of tabs "\n"

    i thought i was looking for "\n" but not sure what COnrtolChars.Lf. Do you mind explaining it to me. Basically my goal is to parse a file and each line in the file has certain number of tabs (space) at the beginning of it. I am trying to count how many tabs cover that space for each line. thanks.

  4. #4
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: Count the number of tabs "\n"

    Code:
    Dim numTabs As Integer = line.Length - line.TrimStart(ControlChars.Tab).Length
    Last edited by David Anton; Aug 9th, 2011 at 03:20 PM.
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

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