Pages

Saturday 22 February 2014

How to limit the input characters to Textbox control And warning if reach the maximum limit Using VB.net


Download the Project Here>>

Use the Following Code



Public Class Form1

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        txtCount.Text = TextBox1.TextLength
    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

        If Asc(e.KeyChar) <> 8 Then
            If txtCount.Text = 20 Then
                e.Handled = True
                Label4.Visible = True
            Else
                Label4.Visible = False
            End If
        Else
            If txtCount.Text = 20 Then
                Label4.Visible = True
            Else
                Label4.Visible = False
            End If
        End If

    End Sub

End Class



No comments:

Post a Comment