I am moving data from a textbox and listbox to validate each line individually, here is my code:
VB Code:
'Move Textbox data to Listbox strParts = Split(txtNotSequential.Text, vbCrLf) For lngIndex = 0 To UBound(strParts) lstCheck.AddItem strParts(lngIndex) Next txtNotSequential.Text = "" 'Move Listbox data back to Textbox For lngIndex = 0 To lstCheck.ListCount - 1 'Checks to see if the number is not less than 11 digits long long If Len(lstCheck) <> 11 Then MsgBox "Please enter a complete Mobile number including the " & vbCrLf & _ "X mobile code 01234", vbInformation, "Invalid Mobile Number" For lngIndex = 0 To lstCheck.ListCount - 1 txtNotSequential.Text = Left$(txtNotSequential.Text, Len(txtNotSequential.Text) - 2) Loop lstCheck.Clear Exit Sub 'Checks to see if the mobile code has been entered ElseIf Mid(lstCheck, 1, 5) <> "01234" Then MsgBox "Please enter the X Mobile Code 01234", vbInformation, "No need for code" For lngIndex = 0 To lstCheck.ListCount - 1 txtNotSequential.Text = Left$(txtNotSequential.Text, Len(txtNotSequential.Text) - 2) Loop lstCheck.Clear Exit Sub End If txtNotSequential.Text = txtNotSequential.Text & lstCheck.List(lngIndex) & vbCrLf Next lstCheck.Clear
The problem I am having it that no matter what data is put into the textbox (even if it is correct) the first msgbox will error? Can anyone help with my coding?
Added [RESOLVED] to thread title and green "resolved" checkmark - Hack




Reply With Quote