Statement return
Statement return
(OP)
Skip,
I was able to fix the For, next issue, but I'm still missing something. My variables are not working, they are returning the same values, and are not capturing the values for all the pages in the statements.
I left the old code so you could see my changes and hopefully my logic with that I am trying to do. Thanks Skip!
James
I was able to fix the For, next issue, but I'm still missing something. My variables are not working, they are returning the same values, and are not capturing the values for all the pages in the statements.
CODE -->
Sess0.Screen.Sendkeys("<Reset>") Sess0.Screen.Sendkeys("<Clear>") Sess0.Save Do Until Sess0.Screen.WaitHostQuiet(g_HostSettleTime) DoEvents Loop Sess0.Screen.Sendkeys("cis "& acnt$) Sess0.Screen.Sendkeys("<Enter>") Sess0.Screen.Sendkeys("css") Sess0.Screen.Sendkeys("<Enter>") Do Until Sess0.Screen.Getstring(02,52,02) <= Sess0.Screen.Getstring(02,60,02) DoEvents Loop For i = 1 To 3 For rw = 5 To 19 Ret1$ = Sess0.Screen.Getstring(rw,04,04) Ret1a$ = Sess0.Screen.Getstring(rw,26,05) Ret1b$ = Sess0.Screen.Getstring(rw,72,08) Sess0.Screen.Sendkeys("<Pf8>") Ret2$ = Sess0.Screen.Getstring(rw,04,04) Ret2a$ = Sess0.Screen.Getstring(rw,26,05) Ret2b$ = Sess0.Screen.Getstring(rw,72,08) WRITE #2,acnt$,Ret1$,Ret1a$,Ret1b$,Ret2$,Ret2a$,Ret2b$ Next ' Next ' Sess0.Screen.Sendkeys("<Pf8>") ' If Sess0.Screen.Getstring(02,52,02) <> Sess0.Screen.Getstring(02,60,02)+1 then ' Do Until Sess0.Screen.Getstring(02,52,02) <= Sess0.Screen.Getstring(02,60,02) ' DoEvents ' Loop ' ' For j = 1 To 3 ' For rw = 5 To 19 ' Ret2$ = Sess0.Screen.Getstring(rw,04,04) ' Ret2a$ = Sess0.Screen.Getstring(rw,26,05) ' Ret2b$ = Sess0.Screen.Getstring(rw,72,08) ' ' WRITE #2,acnt$,Ret2$,Ret2a$,Ret2b$ ' Next Sess0.Screen.Sendkeys("<Enter>") ' Do Until Sess0.Screen.WaitForCursor(01, 02) 'Kept as alernative in event 'Do Until' below doesn't work Do Until Sess0.Screen.WaitHostQuiet(g_HostSettleTime) DoEvents Loop Sess0.Save Next XXX: LOOP CLOSE #1 msgbox "Your macro is complete, have a nice day." End Sub
I left the old code so you could see my changes and hopefully my logic with that I am trying to do. Thanks Skip!
James
RE: Statement return
1) I’m confused.
What about the beginning of your outer loop...
CODE
2) When you SendKeys this...
CODE
And you have a bunch of those, including the <PF8>s.
3) Blocks must be nested. Each Sub...End Sub, each For...Next, each If...Then...End If, each Do...Loop must be totally within a block.
Style wise, I like to indent each block. Procedurally, I enter the skeleton form of my block to insure that I’ve added all the essential elements, and once established, I fill in the particulars. The Excel VBA editor actually helps you out when you set up a Sub or Function, by automatically giving you an End Sub or End Function.
CODE
BTW, I’ve done ALL my Attachmate screen coding in Excel because a) the VBA Editor is soooo much better and b) because my screen scrapes akways begin with a list from Excel and end up as a list in Excel.
Here’s the beginning of a loop...
CODE
Here’s the beginning of an If, where x is just a temporary placeholder...
CODE
I have my block structures in place. Any other blocks must reside totally within an existing block.
Can’t have this...
CODE
Skip,
Just traded in my OLD subtlety...
for a NUance!
RE: Statement return
CODE -->
Thank you again for your help!
James
RE: Statement return
I’d suggest some tips on variables.
Stay away from variable names like
Year, Month, Day, Hour, Minute, Second, Page, Pages
Most are reserve words, Function Names.
Some programmers use naming conventions for variables that give an indication of the Data Type:
i for Integer... Dim iCnt As Integer
l for Long... Dim lRow As Long
s for String... Dim sSQL As String
ws for Worksheet... Dim wsMaster As Worksheet
wb for Workbook... Dim wbAccounts As Workbook
r for Range... Dim rAccounts As Range
o for Object... Dim oScreen As Object
d for Date... Dim dStart As Date, dDate As Date
Once you “format” your declarations, the Excel VBA Editor will provide the capitalization that you provided in your declarations. Same with reserve words like for, next, if, then, else, date, now. It’s a good self-check. If what you thought was a reserve word spelling isn’t, it won’t get capitalized.
Have fun!
Skip,
Just traded in my OLD subtlety...
for a NUance!