Results 1 to 7 of 7

Thread: Counting Caracters in a String(NOT WORKING)

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2009
    Posts
    49

    Question Counting Caracters in a String(NOT WORKING)

    Ok, so I have a string called item. It's value is "Coffe`". When I try to get the number of caractors by using:
    Code:
    textcount = item.length
    However it returns with the value "5". even though there is 6 caracters. Any ideas on how to fix this?

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Counting Caracters in a String(NOT WORKING)

    Is that final thing a separate character, or is it an accented e? It looks like an apostrophe, which is clearly a character.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2009
    Posts
    49

    Re: Counting Caracters in a String(NOT WORKING)

    It is a separate caractor

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Counting Caracters in a String(NOT WORKING)

    If item is a string, then it would have a character array. I would put a breakpoint on the line you posted, and take a close look at item. Every character would count in the length, so this is not making much sense, yet.
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2009
    Posts
    49

    Re: Counting Caracters in a String(NOT WORKING)

    The value is:

    Coffe`

    when I try to find the number of caracters using the code above, it gives me the value

    5

    when it should be 6.
    I think the value

    `
    is not being counted.

  6. #6
    PowerPoster SJWhiteley's Avatar
    Join Date
    Feb 2009
    Location
    South of the Mason-Dixon Line
    Posts
    2,256

    Re: Counting Caracters in a String(NOT WORKING)

    Cutting and pasting that string and I get 6.
    "Ok, my response to that is pending a Google search" - Bucky Katt.
    "There are two types of people in the world: Those who can extrapolate from incomplete data sets." - Unk.
    "Before you can 'think outside the box' you need to understand where the box is."

  7. #7
    Member VB6 to Vb2010's Avatar
    Join Date
    Dec 2010
    Posts
    38

    Re: Counting Caracters in a String(NOT WORKING)

    Quote Originally Posted by domefavor95 View Post
    Ok, so I have a string called item. It's value is "Coffe`". When I try to get the number of caractors by using:
    Code:
    textcount = item.length
    However it returns with the value "5". even though there is 6 caracters. Any ideas on how to fix this?
    Code:
            Dim textcount As Integer
            Dim item As String = "Coffe`"
            textcount = item.length
    This gives me 6.

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