Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Visual Basic Error Message:  Do Without Loop

Posted on 2010-08-12
7
Medium Priority
?
929 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Industry Leaders: 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!

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
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 …
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

610 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