(Solved) – VBScript Do While loop skips part of code when nested

(solved)-–-vbscript-do-while-loop-skips-part-of-code-when-nested

I have this Do…While – Loop VBScript code that works fine in pulling screen data from Bluezone Web-to-Host platform to Excel and then sorting it. However, it requires a passcode to open the records. The variable for this passcode is named CourtCode and the value is in Sheet("Main").Range("B2"). The VBScript works fine in pulling the records for this single passcode

But when I fill in a list of passcodes in Column B of the same sheet and try to loop through, I discover that it will only show the screen of the records and process the first record only.

Here is the VBScript code:

Do While oRow < numberofLoops And Checkr < 1
'For oRow = 1 To numberofLoops

z = 1



'  PF11 - GENERAL LOOK-UPS AND INQUIRY 
bzo.SendKey ""
bzo.WaitReady 10, 1


' Enter court code
bzo.SetCursor 8, 37
bzo.SendKey CourtCode
bzo.SendKey ""
bzo.WaitReady 10, 1

    ' Loop through X entry



    If oRow > 10 And oRow < 21 Then
            z = z   10
            bzo.SendKey ""
            bzo.WaitReady 10, 1
    End If

    If oRow > 20 And oRow < 31 Then
            z = z   20
            bzo.SendKey ""
            bzo.WaitReady 10, 1

            bzo.SendKey ""
            bzo.WaitReady 10, 1
    End If

    If oRow > 30 And oRow < 41 Then
            z = z   30
            bzo.SendKey ""
            bzo.WaitReady 10, 1

            bzo.SendKey ""
            bzo.WaitReady 10, 1

            bzo.SendKey ""
            bzo.WaitReady 10, 1
    End If

  Do While z < oRow     

        bzo.SendKey ""
    bzo.WaitReady 10, 100
        z = z   1
    Loop



    'If oRow = 11 Then 
    '       bzo.SendKey ""
    '       bzo.WaitReady 10, 1
    'End If

bzo.SendKey "x"
bzo.SendKey ""
bzo.WaitReady 10, 1

bzo.SendKey ""
bzo.WaitReady 10, 1

    ' Copy first screen
bzo.Copy rcScreen
wb.Sheets("DATA").Activate
wb.Sheets("DATA").Range("A1").Select
wb.Sheets("DATA").Paste

'Go back
bzo.SendKey ""
bzo.WaitReady 10, 1

bzo.SendKey ""
bzo.WaitReady 10, 1

'Copy second screen
 bzo.Copy rcScreen
wb.Sheets("DATA").Range("N1").Select
wb.Sheets("DATA").Paste

'Go back
bzo.SendKey ""
bzo.WaitReady 10, 1

oRow = oRow   1
eo.Run "Sortr"

Checkr = eo.ActiveWorkbook.Sheets("MAIN").Range("F2").Value

 Loop 

In order to repeat this code with a loop I tried:

Do While i < numberofpasscodes  ' As found in Excel sheet

  CourtCode = eo.ActiveWorkbook.Sheets("MAIN").Range("B" & i).Text
   '''''''''''''''
   '  Block of vbscript loop above
   '''''''''''''''
  i = i   1

Loop

The problem I'm facing is that new loop doesn't take more than one record per passcode. Please help. I dont know if I'm missing anything.

Leave a Reply

Your email address will not be published. Required fields are marked *