Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bug Problem. "Illegal Statement" Help!!!!!

Status
Not open for further replies.

Crash171

Programmer
Sep 5, 2014
30
US
lease help! I'm writing my first If/Then statement within a loop and having a little trouble. When I compile the code the dreaded red bug warning pops up on the last line and I get two errors. They are:

* "Illegal Statement" If I click where "End Sub" is located
* "Unexpected end of file" If I click on the empty line below "End Sub"

Here is the code that I wrote:



Code:
Do Until Sess0.Screen.GetString(20, 12, 5) = "     "
    DoEvents
        Sess0.Screen.MoveTo 11,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 12,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 13,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 14,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 15, 06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 16,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 17,06.
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 18,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 19,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 20,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.Sendkeys("<Enter>")
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime) 
        
	If (Sess0.Screen.GetString(1, 35, 6) = "DELETE") Then
    	    Do Until Sess0.Screen.GetString(1, 35, 6) = "      "
        Sess0.Screen.Sendkeys("<Enter>")
    	Sess0.Screen.Sendkeys(" ")
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime) 
        Sess0.Screen.Sendkeys("<Enter>")

Loop

	System.TimeoutValue = OldSystemTimeout
End Sub
 
the problem may be here
Code:
	If (Sess0.Screen.GetString(1, 35, 6) = "DELETE") Then
    	    Do Until Sess0.Screen.GetString(1, 35, 6) = "      "

you have two Do's and one Loop
 
Yes, I need to figure out how to do a loop within a loop, IF the word DELETE pops up.
 
SkipVought said:
Hi,

1) you're missing an End If on the If statement with = "DELETE"

2) you're missing a Loop on the following Do Until statement.


Do I just write "End If" or can I use something like End If GetString(1, 35, 6) = " "?

Here is where I am now:

Code:
Do Until Sess0.Screen.GetString(20, 12, 5) = "     "
    DoEvents
        Sess0.Screen.MoveTo 11,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 12,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 13,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 14,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 15,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 16,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 17,06.
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 18,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 19,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 20,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.Sendkeys("<Enter>")
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime) 
Loop        
       	If (Sess0.Screen.GetString(1, 35, 6) = "DELETE") Then
    	    Do Until Sess0.Screen.GetString(1, 35, 6) = "      "
        Sess0.Screen.Sendkeys("<Enter>")
    	Sess0.Screen.Sendkeys(" ")
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime) 
        Sess0.Screen.Sendkeys("<Enter>")
        End If GetString(1, 35, 6) = "      "
Loop

	System.TimeoutValue = OldSystemTimeout
End Sub



 
Code:
Do Until Sess0.Screen.GetString(20, 12, 5) = "     "
    DoEvents
        Sess0.Screen.MoveTo 11,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 12,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 13,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 14,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 15, 06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 16,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 17,06.
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 18,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 19,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.MoveTo 20,06
        Sess0.Screen.Sendkeys("D")
        Sess0.Screen.Sendkeys("<Enter>")
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime) 
        
	If (Sess0.Screen.GetString(1, 35, 6) = "DELETE") Then
    	    Do Until Sess0.Screen.GetString(1, 35, 6) = "      "
               Sess0.Screen.Sendkeys("<Enter>")
    	       Sess0.Screen.Sendkeys(" ")
               Sess0.Screen.WaitHostQuiet(g_HostSettleTime) 
               Sess0.Screen.Sendkeys("<Enter>")
            [b]Loop
         End If[/b]

Loop

	System.TimeoutValue = OldSystemTimeout
End Sub
 
Compiled Successfully! Thank you yet again SkipVought!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top