Is this a better way to validate a text box for mobile number only?Validation:allow only numberswill not allow to paste string including charactersallow copy from the boxlength is set to 10 without country codeallow back spaceSuggest some methods to help me improve my function.Public Sub mob_validation(ByVal e As System.Windows.Forms.KeyPressEventArgs, ByVal mob As TextBox)        If e.KeyChar = Chr(22) Then            Dim output As String = New String((From c As Char In Clipboard.GetText.ToString Select c Where Char.IsLetter(c)).ToArray())            If output =  And Len(mob.Text) = 10 Then                mob.ForeColor = Color.Green            Else                mob.ForeColor = Color.Red                Clipboard.Clear()            End If        Else            If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then                If Asc(e.KeyChar) <> 8 Then                    If Asc(e.KeyChar) <> 3 Then                        e.Handled = True                        mob.ForeColor = Color.Red                    End If                End If            Else                mob.ForeColor = Color.Green            End If        End If    End Sub
Is this a better way to validate a text box for mobile number only?
vb.net;validation
Again, properly indent the code. The code was unreadable to the point that we broke our own rules and edited the code in question just to be able to review it.Other than that, the biggest issue with this is all of the magic numbers. They mean absolutely nothing to Mr. Maintainer. Normally at this point, I tell people to create an Enum, but in this case, there's one built in. Use the Keys Enumeration to replace all of those hardcoded numbers. 