Results 1 to 5 of 5

Thread: Looking for a good Character count Algorithm for Textbox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Post

    I am looking for a good Character count Algorithm for Textbox. ie I have a textbox that I can only allow 200 Characters in it. I want to coun't down from 200 when someone types in the textbox. When they use Delete or Backspace and other char's that don't add to the textbox like the arrow keys and function keys I don't want the counter label to count them. I can create one but I was hoping someone would have it done. Yes I guess I am being lazy but I have very little time to get this project done for work and there are alot of other things I need to do. WA!@Wa! Wa! Sorry for the wine. If anyone can help I would appreciate it. Here is code I have now this may help you understand what I am doing. I set the label LblTotNumchr=200 on form load. As you see the code does not take into account the other keys that are not numbers or letters or spaces. It counts everything!

    If KeyCode = vbKeyBack Then
    Counter = LblTotNumchr.Caption + 1
    LblTotNumchr.Caption = Counter
    Exit Sub
    End If
    Counter = LblTotNumchr.Caption
    Counter = Counter - 1
    LblTotNumchr.Caption = Counter
    LblTotNumchr.Refresh


    Thanks Troy

    [Edited by Troy Mac on 10-16-2000 at 03:03 PM]
    TMacPherson
    MIS Systems Engineer
    [email protected]


  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    How about someting simpler:

    LblTotNumchr.Caption = 200 - Len(textfield)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Talking

    Da! Boy do I feel dumb My mind is going in so many dierctions I can't beleive I didn't think of that. Thanks guys you just made my life easier!!

    Troy
    TMacPherson
    MIS Systems Engineer
    [email protected]


  4. #4
    Guest
    Originally posted by JHausmann
    How about someting simpler:

    LblTotNumchr.Caption = 200 - Len(textfield)
    Blah, I put the same, but than I saw him saying something about arrow keys and spaces he did not want to count and I got all confused, so I deleted it .

    Oh well, at least I had the same idea.

  5. #5
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Yes, you did. And only a minute (or less) ahead of me

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