check for data if another combobox has data

I have the following comboboxes below:
ComboA1         ComboB1
ComboA2         ComboB2
ComboA3         ComboB3
.......                  ..............

I want to write some VB6 code that will check all the comboboxes from A1 to A5.  If any of them have any text in them, then the code will have to check the equivalent combobox in the right column (B1 to B5) to make sure that has text also.  If it doesn't then the user will need to enter data.  How can I accomplish this?
Who is Participating?
VBClassicGuyConnect With a Mentor Commented:
If Len(ComboA1.Text) Then
   If Len(ComboB1.Text) = 0 Then
      Rem *** Insert data-entering routine here ***
   End If
End If

Repeat the above for Combo 2 to 5.

But ya know, a slicker way to do it is to make an array of comboboxes. For instance:

ComboA1 becomes cboData(0)
ComboA2 becomes cboData(1)
ComboA3 becomes cboData(2)
ComboA4 becomes cboData(3)
ComboA5 becomes cboData(4)
ComboB1 becomes cboData(5)
ComboB2 becomes cboData(6)
ComboB3 becomes cboData(7)
ComboB4 becomes cboData(8)
ComboB5 becomes cboData(9)

Then you can use:

For i = 0 to 4
   If (Len(cboData(i).Text ) > 0) And (Len(cboData(i + 5).Text ) = 0) Then
      Rem *** Insert data-entering routine here ***
   End If
Next i
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.