Stuck in a Loop
Hi there,
I have a user interface that I use to enter employee data including socials which are stored as a string. When validating the data, I'm getting stuck in a loop. Basically, if a user doesn't enter anything in the box or if the data isn't a digit, an input box pops up and asks them to reenter the data. However, even if the user enters the appropriate number of characters, they get stuck in a loop.
Private Sub saveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles saveButton.Click
Dim SSN As String
Dim SSN_COPY As String
Dim SSN_FIRST As String
Dim SSN2 As String
Dim SSN_LAST As String
Dim SSN_MID As String
If ssnTextBox.Text = String.Empty Then
Do
SSN = InputBox("Enter a 9-digit social security number (no dashes)", "Soc Sec Number")
Loop Until SSN.Length = 9 And (ssnTextBox.Text Like "#########")
ElseIf ssnTextBox.Text.Length <> 9 Then
Do
SSN = InputBox("Enter a 9-digit social security number (no dashes)", "Soc Sec Number")
Loop Until SSN.Length = 9 And (ssnTextBox.Text Like "#########")
ElseIf Not (ssnTextBox.Text Like "#########") Then
Do
SSN = InputBox("Enter a 9-digit social security number (no dashes)", "Soc Sec Number")
Loop Until ssnTextBox.Text.Length = 9 And (ssnTextBox.Text Like "#########")
End
Else
SSN = ssnTextBox.Text
SSN_COPY = SSN
SSN_FIRST = SSN_COPY.Remove(3, 6)
SSN_LAST = SSN_COPY.Remove(0, 5)
SSN2 = SSN_COPY
SSN_COPY = Mid(SSN2, 4, 2)
SSN_MID = SSN_COPY
ssnTextBox.Text = (SSN_FIRST & "-" & SSN_MID & "-" & SSN_LAST)
End If
Any suggestions? Thanks!
Trixie
|