For valCounter = 0 To 11? Did you add another 3 textboxes? I'm going to assume you've placed them on Form4...
----------------------------------
Private Function CheckForDuplicates(txt1 as Object, txt2 as Object, txt3 as Object, txt4 as Object) as Integer
'Store all values into Values() array:
For valCounter = 0 To 8
Select Case valCounter
Case 0, 1, 2
Values(valCounter) = txt1(indxCounter).Text
Case 3, 4, 5
Values(valCounter) = txt2(indxCounter).Text
Case 6, 7, 8
Values(valCounter) = txt3(indxCounter).Text
Case 9, 10, 11
Values(valCounter) = txt4(indxCounter).Text
End Select
indxCounter = indxCounter + 1
If indxCounter = 3 Then indxCounter = 0
Next valCounter
For valCounter = 0 To 11
tmpValue = Values(valCounter)
For indxCounter = (valCounter + 1) To 11
If tmpValue = Values(indxCounter) And tmpValue <> "" Then
CheckForDuplicates = valCounter 'found dupe, return valCounter
Exit Function 'and get out
End If
Next indxCounter
Next valCounter
End Function
Private Sub Command1_Click()
Dim ReturnValue as Integer
ReturnValue = CheckForDuplicates(Form1.txtNumbers, Form2.txtNumbers, Form3.txtNumbers, Form4.txtNumbers)
Select Case ReturnValue
Case 0, 1, 2
Form1.txtNumbers(ReturnValue).SetFocus
Case 3, 4, 5
Form2.txtNumbers(ReturnValue- 3).SetFocus
Case 6, 7, 8
Form3.txtNumbers(ReturnValue- 6).SetFocus
Case 9, 10, 11
Form4.txtNumbers(ReturnValue - 9).SetFocus
End Select
End Sub
Hope that does it!
-Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.
-Ben Franklin