5 Replies - 1363 Views - Last Post: 14 October 2011 - 09:45 PM Rate Topic: -----

#1 karthickraghuram  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 11-October 11

Validate two conditions through maskedtext box.

Posted 11 October 2011 - 11:22 AM

Hi,
I have been using masked text box in a project.I have learnt that there is an option that allows to enter a number or a space.But I want to make the masked text box to accept an alphabet or a space..Is there any mask option available to do this?




Thanks in Advance.
Is This A Good Question/Topic? 0
  • +

Replies To: Validate two conditions through maskedtext box.

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4399
  • View blog
  • Posts: 12,255
  • Joined: 18-April 07

Re: Validate two conditions through maskedtext box.

Posted 11 October 2011 - 02:34 PM

Check out using the '?' mask character. I believe this might allow spaces too. If not, you can look through the following page and see which of these characters will best match what you are trying to do (even though I think none of them will EXACTLY match).

Using the MaskedEdit Control - MSDN

:)
Was This Post Helpful? 1
  • +
  • -

#3 karthickraghuram  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 11-October 11

Re: Validate two conditions through maskedtext box.

Posted 12 October 2011 - 11:00 AM

Hi,
The option '?' restricts me to enter only Alphabet.Space is not allowed.I think there won't be any option that meets criteria.If found any please let me know.It will be very useful to me.




Thanks.
Was This Post Helpful? 0
  • +
  • -

#4 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,793
  • Joined: 26-March 09

Re: Validate two conditions through maskedtext box.

Posted 13 October 2011 - 10:22 PM

My understanding is that the masked edit is for entering numbers and letters in a format.

So for example if the mask was "?? ##" the input could be "AB 12", but it can't be "12 AB", because of the mask format.

If entry format is a fixed format like I've put above, you can automatically enter the spaces in the mask so the user doesn't need to key them,

If you need the flexibility you refer to, then maybe a standard textbox would be suitable and then enable the keys allowed in the "key" events.
Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Validate two conditions through maskedtext box.

Posted 14 October 2011 - 10:45 AM

You can also use the KeyPress event in the masked edit control. It's a little complicated, though, because the user could hit the backspace key or click the mouse somewhere other than the end of the string. (You may want to force the user to not do that, checking the click event and placing the cursor at the end of the string if it isn't there.)

Once you have all that worked out: if, say, the 5th character needs to be either an alpha character or a space, then use the len function to evaluate the length of the existing string. If it's 4, then check the KeyAscii value, see if it matches the allowed characters, and beep and disable if it doesn't. (Make sure that you allow a Backspace key through.)

This post has been edited by BobRodes: 14 October 2011 - 01:06 PM

Was This Post Helpful? 1
  • +
  • -

#6 karthickraghuram  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 11-October 11

Re: Validate two conditions through maskedtext box.

Posted 14 October 2011 - 09:45 PM

Thanks Bob.Got an idea.I'l try the same.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1