I am attempting to keep user inputs into our application as clean as possible. One way I am attempting to do this is not allowing incorrect data type in fields (not allowing alpha characters when expecting numeric values)
I found and implemented the following code:
Private Sub txtSocial_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtSocial.KeyPress
Dim UserKeyPress As Char = e.KeyChar
Dim isKey As Boolean = e.KeyChar.IsDigit(UserKeyPress)
Dim isCont As Boolean = e.KeyChar.IsControl(UserKeyPress)
If Not isKey And Not isCont Then
e.Handled = True
End If
The code works as desired however Visual Studio throws this warning:
Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.
I am not opposed to warnings, but I would like to know if there is whether I ignore the warning and move on, or is there a better way to accomplish my goals?