'Keeps user from entering anything but numbers
Dim charactersDisallowed As String = "`~!@#$%^&*()_+-={}|[]\:;<,>.?/'qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM"""
'checks the text that the user enters for the card number
Private Sub txtCustCardNumber_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCustCardNumber.TextChanged
Dim theText As String = txtCustCardNumber.Text
Dim Letter As String
Dim SelectionIndex As Integer = txtCustCardNumber.SelectionStart
Dim Change As Integer
For x As Integer = 0 To txtCustCardNumber.Text.Length - 1
Letter = txtCustCardNumber.Text.Substring(x, 1)
If charactersDisallowed.Contains(Letter) Then
theText = theText.Replace(Letter, String.Empty)
Change = 1
End If
Next
txtCustCardNumber.Text = theText
txtCustCardNumber.Select(SelectionIndex - Change, 0)
End Sub
'checks the text that the user enters for the pin number
Private Sub txtCustCardPin_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCustCardPin.TextChanged
Dim theText As String = txtCustCardPin.Text
Dim Letter As String
Dim SelectionIndex As Integer = txtCustCardPin.SelectionStart
Dim Change As Integer
For x As Integer = 0 To txtCustCardPin.Text.Length - 1
Letter = txtCustCardPin.Text.Substring(x, 1)
If charactersDisallowed.Contains(Letter) Then
theText = theText.Replace(Letter, String.Empty)
Change = 1
End If
Next
txtCustCardPin.Text = theText
txtCustCardPin.Select(SelectionIndex - Change, 0)
End Sub
****I THINK THAT THIS IS THE LINE I'M HAVING TROUBLE WITH...***
Private currentTextBox As New TextBox
Private Sub txtCustCardNumber_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCustCardNumber.GotFocus
currentTextBox = sender
End Sub
Private Sub txtCustCardPin_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCustCardPin.GotFocus
currentTextBox = sender
End Sub