Solved

Visual Basic Error Message:  Do Without Loop

Posted on 2010-08-12
7
916 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
  • 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now