Article
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    APIs
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog

Home >> VB.Net >> MaskedTextBox Control in VB.Net
MaskedTextBox Control in VB.Net
MaskedTextBox Control in VB.Net


by Pushpendra Singh on 12/12/2010 3:39:16 PM

Views: 4249       Comments: 0

MaskedTextBox Control in VB.Net

A MaskedTextBox control provides validation mechanism for user input on a Form. By default Masked property is set to None and the control works like a normal TextBox control.

How use MaskedTextBox Control

Drag and drop MaskedTextBox and Button (change its caption to Submit) control from toolbox on the window Form.

MaskedTextBox Control in VB.Net

Code:

Public Class Form10

 

    Private Sub Form10_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Here TextBox is masked as number show you can enter number only

        MaskedTextBox1.Mask = "00000000000000000"

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        'Enter number will show in Label

        Label2.Text = "Entered Number is  " + MaskedTextBox1.Text

    End Sub

End Class

 

Run the project

MaskedTextBox Control in VB.Net

When you enter other than number then masketextbox will not accept.Because in code mask is specified as  MaskedTextBox1.Mask = "00000000000000000" which means it will accept only number.

MaskedTextBox Control in VB.Net

When you enter number and click Submit Button then click event of submit button will fire and entered number will show in the Label.

MaskedTextBox Property

UseSystemPasswordChar: Gets or sets a value indicating as password character.

Private Sub Form10_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ' entered number will show as password

        MaskedTextBox1.UseSystemPasswordChar = True

End Sub

MaskedTextBox Control in VB.Net

ForeColor:

ForeColor of MaskedTextBox can be changed through ForeColor property of MaskedTextBox.

Private Sub Form10_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'change ForeColor of MaskedTextBox

        MaskedTextBox1.ForeColor = Color.Red

End Sub

ForeColor  of MaskedTextBox will be changed.

MaskedTextBox Control in VB.Net

Report Abuse Form
Reason:    
 

Title :
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
     
 
Latest Article by Pushpendra SinghRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 6162
Advertisement
MindStick Cleaner
Advertise with Us
  
Copyright © 2013MindStick. All Rights Reserved.