Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2002
    Posts
    173

    Unanswered: adding characters

    Is it possible when a user enters info into a field you can add a specific character at specific intervals automatically. I'd like to setup a field to enter in dashes "-" at specific entry points but without using a specified "format" or "input mask".

    Here's an example.

    The user types in 3344443

    The code will place a dash whenever a certain length has been reached. When the field reaches 2 characters a dash will be entered automatically, when it reaches a length of 7 another dash will enter automatically, and so on.

    33-4444-3

    Any ideas?

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    You can use any of the key events (keydown,keyup,keypress) and use the len function of the text box to determine your logic to insert your own "mask".

  3. #3
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    91
    You should use the len of textbox.Text property
    Hm... can you just add the "-" (I think the cursor will go back to the first char again..., but I don't know... haven't try it ) Instead, you can use SendKeys.

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    The len function was only mentioned to determine position for the logic of the user-defined mask. How you append the masking characters is left up to the programmer - however, be aware that sendkeys is buggy.

  5. #5
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    91
    How can we control the position of cursor on the textbox? What do you suggest as an alternative of sendkeys?

  6. #6
    Join Date
    Feb 2002
    Posts
    2,232
    Explain what you mean by "control the position of cursor on the textbox".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •