Now when I use this code on masked textbox does not work
What do you mean by "does not work"? If it doesn't function then you should have an error/exception message.
Or is it working (no error) just not behaving as you thought it would?
It's simple enough to see *why* it does what it does/thinks what it thinks, and see if your assumptions are right.
- Put a breakpoint on line 1.
- When the code stops there, walk through line by line with F-10.
- Check the values of your assumptions.
Having the 'locals' and 'auto' pallets open will show you those variables and their values.
Hovering the mouse over a code segment such as textbox.text will show you it's value.
Your 'if' construct is centered on the assumption that the textbox.text will be empty: So confirm that. When it breaks on that line, hover your mouse over the
textbox.text and see what its value really is. You might be surprised to find out that it isn't blank.