Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How can restrict text in a textbox to specific length of words on run time in VB.

Author: DevASP
Download Source Code : 563_restrict_textbox.zip

In this simple article you will learn that how you can restrict text in a textbox to specific length of words.

 Simply just create New Project of console application in VB.

 Drag one text box having name txtname and one button and one numericupdown.

 Create two global variables

 

 

Dim namee As String = ""

Dim len As Integer = 5

 

Now just write code against these events

 

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

   

    Me.Text = "DevAsp"

     

  txtname.Text = ""

 

  End Sub

 

 

  Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtname.TextChanged

     

  If txtname.Text.Length > len Then

   

        txtname.Text = namee

    

   Else

            namee = txtname.Text

   

    End If

  

 End Sub

  

 

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

  

     len = NumericUpDown1.Value

 

  End Sub

Article Comments
How can restrict text in a textbox to specific length of words on run time in VB.

Posted on 4/6/2007 2:48:06 AM by Senthil Kumar

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Creating a Bouncing Ball Game on Win Form.

Disclaimer - Privacy
© 2002-2017 DevASP.net