Sunday, February 12, 2012

VB.NET Limit textbox minimum and maximum characters

Let's imagine that you hava a textbox for a user to input something and you want that to be between a minimum and a maximum number of characters, how you do it on VB.NET? Let's see!

Code:

Maximum size limitation can be done in the textbox properties in the "MaxLenght" option.

textbox vb.net
To minimum size limitation it's only necessary to check when user clicks the button to send that information.

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

    Private Sub check_text()
        If TextBox1.Text.Length = 3 Then
            MessageBox.Show("Ok")
        Else
            MessageBox.Show("You need to insert 3 numbers")
        End If
    End Sub


Video tutorial:


2 comments:

  1. thx you so much my friend,i have been looking for this answer since 2 weeks ago.i m really proud of it.so right now ,if you could send me how to show pictures from access database 2007 to visual studio 2010,i d really appreciate that.i d like to put it in my project.

    ReplyDelete
  2. how can i process the fraction in the textbox?

    ReplyDelete