Loop Structures in VB6.0

suppose there are 5 values in a table..i am fetching the values using while loop..
while fetching the 3rd value some of the values doesnt match with the validation criterion..
so i need to move on to the next value in the loop without fetchin this one...
how can i do this without using GOTO statement....
give suggestion....

Eg:

 Do While bRet = True
   
             gsInvNo = UCase(Trim$(eSheet.Cells(iRwCnt, 1)))
             
             If gsInvNo = "Null" Then
               gsInvNo = ""
             End If
               
             gsInvDate = UCase(Trim$(eSheet.Cells(iRwCnt, 2)))
             gsInvType = UCase(Trim$(eSheet.Cells(iRwCnt, 3)))
              If gsInvType = "NULL" Then
               gsInvType = ""
             End If
             gsSupCode = UCase(Trim$(eSheet.Cells(iRwCnt, 4)))
              If gsSupCode = "NULL" Then
               gsSupCode = ""
             End If
             gsInvAmt = UCase(Trim$(eSheet.Cells(iRwCnt, 5)))
              If gsInvAmt = "NULL" Then
               gsInvAmt = ""
             End If
             gsPoRefNo = UCase(Trim$(eSheet.Cells(iRwCnt, 6)))
              If gsPoRefNo = "NULL" Then
               gsPoRefNo = ""
             End If
loop
lazziebobAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
something like this:

dim blnTakeRecord as boolean

Do While bRet = True
      blnTakeRecord = true

             gsInvNo = UCase(Trim$(eSheet.Cells(iRwCnt, 1)))
             
             If gsInvNo = "Null" Then
               gsInvNo = ""
               blnTakeRecord = false
             End If
             
             if blnTakeRecord then  
               gsInvDate = UCase(Trim$(eSheet.Cells(iRwCnt, 2)))
               gsInvType = UCase(Trim$(eSheet.Cells(iRwCnt, 3)))
                If gsInvType = "NULL" Then
                 gsInvType = ""
                 blnTakeRecord = false
               End If
             end if

             if blnTakeRecord then
               gsSupCode = UCase(Trim$(eSheet.Cells(iRwCnt, 4)))
                If gsSupCode = "NULL" Then
                 gsSupCode = ""
                 blnTakeRecord = false
               End If
             end if

            if blnTakeRecord then
             gsInvAmt = UCase(Trim$(eSheet.Cells(iRwCnt, 5)))
              If gsInvAmt = "NULL" Then
               gsInvAmt = ""
                 blnTakeRecord = false
             End If
            end if

            if blnTakeRecord then
             gsPoRefNo = UCase(Trim$(eSheet.Cells(iRwCnt, 6)))
              If gsPoRefNo = "NULL" Then
               gsPoRefNo = ""
                 blnTakeRecord = false
             End If
           end if

      if blnTakeRecord then
          'do what you want with the record
      end if
loop

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rbvoigtCommented:
Better is a nested once-through loop, by exiting the inner loop you reach the bottom of the outer loop.

 Do While bRet = True
    Do
             gsInvNo = UCase(Trim$(eSheet.Cells(iRwCnt, 1)))
             
             If gsInvNo = "Null" Then
               gsInvNo = ""
               Exit Do
             End If
               
             gsInvDate = UCase(Trim$(eSheet.Cells(iRwCnt, 2)))
             gsInvType = UCase(Trim$(eSheet.Cells(iRwCnt, 3)))
              If gsInvType = "NULL" Then
               gsInvType = ""
               Exit Do
             End If
             gsSupCode = UCase(Trim$(eSheet.Cells(iRwCnt, 4)))
              If gsSupCode = "NULL" Then
               gsSupCode = ""
               Exit Do
             End If
             gsInvAmt = UCase(Trim$(eSheet.Cells(iRwCnt, 5)))
              If gsInvAmt = "NULL" Then
               gsInvAmt = ""
               Exit Do
             End If
             gsPoRefNo = UCase(Trim$(eSheet.Cells(iRwCnt, 6)))
              If gsPoRefNo = "NULL" Then
               gsPoRefNo = ""
               Exit Do
             End If
    Loop Until True
loop
0
rbvoigtCommented:
Of course you can also put the loop action in a function, and use exit function to skip to the next iteration
0
prafful_nagwaniCommented:
'General Declaration
Dim blnTest As Boolean

Private Function CheckSub(testString As String)
    blnTest = True
    If testString = "NULL" Or testString = Empty Then blnTest = False
End Function

Private Sub Test()
    bRet = True
    Do While bRet = True
        gsInvNo = UCase(Trim$(eSheet.Cells(iRwCnt, 1))): CheckSub (gsInvNo)
        If blnTest = True Then gsInvDate = UCase(Trim$(eSheet.Cells(iRwCnt, 2))): CheckSub (gsInvDate)
        If blnTest = True Then gsInvType = UCase(Trim$(eSheet.Cells(iRwCnt, 3))): CheckSub (gsInvType)
        If blnTest = True Then gsSupCode = UCase(Trim$(eSheet.Cells(iRwCnt, 4))): CheckSub (gsSupCode)
        If blnTest = True Then gsInvAmt = UCase(Trim$(eSheet.Cells(iRwCnt, 5))): CheckSub (gsInvAmt)
        If blnTest = True Then gsPoRefNo = UCase(Trim$(eSheet.Cells(iRwCnt, 6))): CheckSub (gsPoRefNo)
    Loop
End Sub

Private Sub Form_Load()
    Test
End Sub
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

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.