?
Solved

Visual Basic Error Message:  Do Without Loop

Posted on 2010-08-12
7
Medium Priority
?
928 Views
Last Modified: 2013-11-25
I have the following Visusal Basic code and is getting an error message when running the code.  The error message is:  Compile Error:   Do Without Loop.   What am I missing?

VB Code.

Public Sub EFeed()
Range("a2").Activate

        MyScn.SendKeys "<Clear>"                            'hit clear twice
        MyScn.SendKeys "<Clear>"
        MyScn.SendKeys "scma<ENTER>"                        'type sjen
   
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
        account = ActiveCell.Value
        MyScn.PutString account, 14, 35
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
        Do While Not IsEmpty(ActiveCell)

        MyScn.PutString "3", 21, 9
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
Do While Not IsEmpty(ActiveCell)
        ADM = ActiveCell.Offset(0, 1).Value
        MyScn.PutString ADM, 15, 49
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
                       
        If MyScn.GetString(24, 18, 12) = "SUCCESSFULLY" Then
            ActiveCell.Offset(0, 2) = "OK"
        Else: ActiveCell.Offset(0, 2) = "NOT PROCESSED"
        End If
       
        If IsEmpty(ActiveCell.Offset(1, 0)) Then Exit Do
       
        ActiveCell.Offset(1, 0).Activate
        account = ActiveCell.Value
        MyScn.PutString account, 23, 17
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
Loop


End Sub
0
Comment
Question by:ArisaAnsar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 3

Expert Comment

by:madhubabus
ID: 33421654
loop statement missing for the below line

        Do While Not IsEmpty(ActiveCell)
0
 
LVL 3

Expert Comment

by:madhubabus
ID: 33421672
there are 2 such statements and only one closing "loop" exists.

        Do While Not IsEmpty(ActiveCell)
0
 

Author Comment

by:ArisaAnsar
ID: 33421720
Thank you for responding so quickly.    I see closing loop for both.  Which of the two do you see it missing from?  

Do While Not IsEmpty(ActiveCell)

        MyScn.PutString "3", 21, 9
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
Do While Not IsEmpty(ActiveCell)
        ADM = ActiveCell.Offset(0, 1).Value
        MyScn.PutString ADM, 15, 49
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:madhubabus
ID: 33421764
................
..........
        Do While Not IsEmpty(ActiveCell)                    ////////////////loop is missing for this do while

        MyScn.PutString "3", 21, 9
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
Do While Not IsEmpty(ActiveCell)                             /////////////////////This is closed at the end
        ADM = ActiveCell.Offset(0, 1).Value
        MyScn.PutString ADM, 15, 49
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
                       
        If MyScn.GetString(24, 18, 12) = "SUCCESSFULLY" Then
            ActiveCell.Offset(0, 2) = "OK"
        Else: ActiveCell.Offset(0, 2) = "NOT PROCESSED"
        End If
       
        If IsEmpty(ActiveCell.Offset(1, 0)) Then Exit Do
       
        ActiveCell.Offset(1, 0).Activate
        account = ActiveCell.Value
        MyScn.PutString account, 23, 17
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
Loop                                                   ////////////////// this loop for the second while
0
 

Author Comment

by:ArisaAnsar
ID: 33421871
Where would the other Loop statement have to placed?  I tried a few options but getting a debug error.
0
 
LVL 3

Accepted Solution

by:
madhubabus earned 1500 total points
ID: 33421948
It depends on your business logic.
From the code what I understood is , add "loop" above the second while loop

       Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       
        Do While Not IsEmpty(ActiveCell)

        MyScn.PutString "3", 21, 9
       
        MyScn.SendKeys "<ENTER>"
        Do While MyScn.OIA.XStatus <> 0                     'wait until the screen comes up
            DoEvents
        Loop
       loop                                                                  ///////////add loop here
Do While Not IsEmpty(ActiveCell)                                
        ADM = ActiveCell.Offset(0, 1).Value
        MyScn.PutString ADM, 15, 49      
        ...
       ...
loop
0
 

Author Closing Comment

by:ArisaAnsar
ID: 33422291
Thank you.
I needed to remove the Do While Not IsEmpty (ActiveCell).

Thank you!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question