I have a text box named "Cell Number". I have set the maxlength to 11 characters. The problem is that it is not saving the number in database. If it is of length <= 10 it easily saves the number. I have inserted a tryParse function so that if any user inserts string so it should prompt an error. I am definitely sure that this error is because of this tryParse function. I tried to set the maxlength property in form_load procedure and on a button_click procedure but it does not work.
Dim emp_cellno As Integer
If Integer.TryParse(TextBox7.Text, emp_cellno) Then
dsNewRow.Item("emp_cellno") = emp_cellno
Else
MsgBox("Kindly Enter Employee's Cell Number")
TextBox7.Text = ""
TextBox7.Focus()
Exit Sub
End If
When I run this code so whenever the characters length is >10 it prompts me a message "Kindly Enter Employee's Cell Number". I don't need Only solution I need an explanation too ?