5 Replies - 1588 Views - Last Post: 19 June 2013 - 02:31 PM Rate Topic: -----

#1 Mucca   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 24-May 13

Masked Text Box Limitations

Posted 19 June 2013 - 01:44 PM

What is the best way to limit the textbox to only accepting numbers from 1-3? if any number above that is entered, nothing will appear and a will beep will sound? Would I include it in formload or do I create a function for it? if possible can someone give me an example code?
Is This A Good Question/Topic? 0
  • +

Replies To: Masked Text Box Limitations

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15175
  • View blog
  • Posts: 60,742
  • Joined: 12-June 08

Re: Masked Text Box Limitations

Posted 19 June 2013 - 01:50 PM

Neither the limiting to the numbers 1, 2, 3, or beeping when not that are baked in options for a masked textbox. What you would do is hook int a textbox's "key pressed" event... and inspect each key as they come in.. if it is not a 1,2, or 3 then make your beep sound.. else let it through.
Was This Post Helpful? 0
  • +
  • -

#3 Mucca   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 24-May 13

Re: Masked Text Box Limitations

Posted 19 June 2013 - 01:52 PM

Not being a leech or anything, but can you please give me a code as an example. They VB.net book I bought doesn't teach me this.
Was This Post Helpful? 0
  • +
  • -

#4 Mucca   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 24-May 13

Re: Masked Text Box Limitations

Posted 19 June 2013 - 01:58 PM

Also can someone fix up this code, I am trying to make it so when a digit is entered, the focus moves to the next masked textbox, however when I backspace it stays in the same position.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15175
  • View blog
  • Posts: 60,742
  • Joined: 12-June 08

Re: Masked Text Box Limitations

Posted 19 June 2013 - 02:08 PM

Naw - it's pretty straight forward use of the control's event and looking at what the event variable tells you. How about you go experiment?


Quote

They VB.net book I bought doesn't teach me this.

Yeah - synthesizing new and interesting things are typically not in the well worn path of a book or course material. Sure it tells you about a rock, and sure it tells you about a stick.. but to jam that rock on a stick to make a hatchet is typically something you need to use your smarts for.

Again - go experiment.

Posted Image
Was This Post Helpful? 0
  • +
  • -

#6 lar3ry   User is offline

  • Coding Geezer
  • member icon

Reputation: 314
  • View blog
  • Posts: 1,296
  • Joined: 12-September 12

Re: Masked Text Box Limitations

Posted 19 June 2013 - 02:31 PM

View PostMucca, on 19 June 2013 - 02:58 PM, said:

Also can someone fix up this code, I am trying to make it so when a digit is entered, the focus moves to the next masked textbox, however when I backspace it stays in the same position.

Simple. In the TextBox_Changed event, check the value entered. Ignore it and clear the TextBox if it's not 1, 2, or 3. If it's 1, 2, or 3, change focus to wherever you want it.

Come on... you can do it.

This post has been edited by lar3ry: 19 June 2013 - 02:32 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1