Also, the more tests you are performing, the slower your app might become. For more information regarding Regular Expressions, you are welcome to look at these two MSDN articles: Because it is always easy to learn by doing things practically, you will be creating an app that makes use of Regular Expressions to determine valid input. NET application and design the form to resemble Figure 1. Obviously this only works for the formatting of the email. This means that as a programmer, you have the power to supply the exact pattern for the input you desire in any text input field. Again, certain special characters are obviously not allowed.

Based on each of these variables' values, we will know if the data is correct or not. The Leave event fires when the control loses focus. As you can see, Regular Expressions are a vital tool to have at your disposal, so become good friends with them.

A name doesn't generally contain weird symbols, and definitely not numbers. This can be from the mouse clicking inside another field, or a Tab key being pressed to navigate to the next input control. ") Else Email Valid = True 'Email is Perfect End If Else 'Not A Match To Pattern Email Valid = False 'Set Boolean Variable To False Message Box. I hope you have learned from this article and that you have enjoyed it as much as I did.

You can also set borders style of a Masked Text Box by using the Border Style property.

The Border Style property is represented by a Border Style enumeration that has three values â€" Fixed Single, Fixed3D, and None.

A Masked Text Box control accepts user input on a Form.

In this article, we discussed discuss how to create a Masked Text Box control in Windows Forms at design-time as well as run-time.Once a Masked Text Box control is ready with its properties, next step is to add the Masked Text Box control to the Form. You can open Properties window by pressing F4 or right click on a control and select Properties menu item. The Location property takes a Point that specifies the starting position of the Masked Text Box on a Form.The Size property specifies the size of the control.After that, we saw how to use various properties and methods.Well, sometimes a good structured and thought out If statement can suffice, but it can become quite long and cumbersome in the future. By using Regular Expressions this way, you can reduce the chances of getting errors at erratic times. This sub checks the email's format and if it thinks that it matches, it returns True and vice versa.NETVisual Basic Tutorials Allow Numbers only in a Text Box - Visual Basic .