Solved

Visual Basic Error Message:  Do Without Loop

Posted on 2010-08-12
7
925 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

707 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