How to find length of string in vb.net

How to find length of string in vb.net
=====================================================================================
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim i As Integer = Len(TextBox1.Text)
MsgBox(i)

End Sub
=====================================================================================
This function tells you how many characters are in a string. You may want to
let users know that their response is too wordy for your database’s allotted
space for a particular entry. Or perhaps you want to see if they entered the
full telephone number, including their area code. If they did, the number will
have to be at least 10 characters long. You can use the less-than symbol (<) to test their entry, like this:
=====================================================================================
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Len(TextBox1.Text) < 10 Then
MsgBox("Shorter")
End If
End Sub
=====================================================================================

No comments: