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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to search a screen for a user input

Status
Not open for further replies.

nyrtfleury14

Technical User
Apr 10, 2012
6
0
0
US
Okay, so I have pieced together this macro from my basic understanding of them and from other existing macros. Basically, I want to be able to loop through a screen and have it find a search input that could be in Rows 8-17, from column 35-column 59, on page 1 through page 50. Pretty much I want to be able to enter 'John' in my search and have it find the JOHN in 'JOHN R SAMPLE'. Once it finds it I want to to say that it found it and ask if the macro wants to stop or continue.


Screen Sample:
FUNCTION ___ SELECT xxxxxxxx_________________ PW
08:04 03/19/13 PG 1
AKF PRC XXXXXXX XXXXX XXXXXXX SYSTEM COB 03/18/13
XXXXXXXXXXX XXXXXXXX SCREEN
TYPE1 _____ TYPE2 _____ POST/TRAN P MONTH __ STMT/CALNDR C
CHK# ________ ________ DATE 03/19/13 AMT _____________
S ST DATE TYPE TRANS AMOUNT DESCRIPTION
_ PD 03/18/13 XXXXX xxx.xx 00056949 JOHN R SAMPLE
_ PD 03/18/13 XXXXX xxxx.xx 00056950 FRANK F SAMPLE
_ PD 03/18/13 XXXXX xxxx.xx SAMPLE
_ PD 03/18/13 XXXXX xxxx.xx SAMPLE
_ PD 03/18/13 XXXXX xx.xx 00056820 JESSICA P PERSON
_ PD 03/18/13 XXXXX xxx.xx 00056694 JENNIFER G SMITH
_ PD 03/18/13 XXXXX xxx.xx 00057003 DOUG E DOUG
_ PD 03/18/13 XXXXX xxxx.xx 00056942 GEOFF JEFFERSON
_ PD 03/18/13 XXXX xxxx.xx SAMPLE
_ MO 03/18/13 XXXX xxxx.xx SAMPLE
<MORE>
<?>= ACTION HELP ACTION ________


What I've got:
Sub Main

Dim Sys As Object, Sess As Object, MyScreen As Object
Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen

Msgtext = "Enter the ML account #"
ML_num$ = Inputbox$(Msgtext, "AKF Search"," ",125%, 100%)
MyScreen.WaitHostQuiet(50)

Msgtext = "Enter all or part of the payee name"
P_name$ = Inputbox$(Msgtext, "AKF Search"," ",125%, 100%)
MyScreen.WaitHostQuiet(50)

P_name$ = UCase(P_name$)

myscreen.sendkeys("<clear>")
MyScreen.WaitHostQuiet(10)
myscreen.sendkeys("AKF <enter>")
MyScreen.WaitHostQuiet(10)
action = myscreen.putstring(ML_num$,01,26)
MyScreen.WaitHostQuiet(10)
myscreen.sendkeys("<enter>")
MyScreen.WaitHostQuiet(10)

IsMore$ = myscreen.getstring(18,29,04)

While (IsMore$ = "MORE")

test_string$ = myscreen.getstring(ROW%,35,25)

From here out I want it to look for P_name$ within all of the test_string$ from the page and tell me if it finds it. If it doesn' then I want it to hit enter and search the next page and so on.

Any help?!?!?
 
Whoa, I did it.

Here is the rest of the code.

While (IsMore$ = "MORE")
ii = 0
for i = 8 to 17 step 2
ii = ii + 1

test_string$ = myscreen.getstring(i,35,25)
Pos = InStr(test_string$, PA_name$)
If pos <> 0 then
'stop here
Begin Dialog UserDialog 185, 54, "AKF Search"
Text 9, 5, 69, 20, "Item Found : Continue?"
OKButton 113,14,54, 13
CancelButton 113,33,54, 13
End Dialog
Dim mydialog as UserDialog
On Error Goto TheEnd
Dialog mydialog
MyScreen.WaitHostQuiet(10)
End if
next i
myscreen.sendkeys("<enter>")
MyScreen.WaitHostQuiet(10)
Wend

close
action = msgbox("MACRO FINISHED")
TheEnd:
End Sub
 
nyrtfleury14, could I bother you to look at a macro I have? I'm getting a "Type Mismatch" error and don't understand. The macro doesn't seem too technical, but can't figure out why I get the message. If you agree, I will post.

Thanks in advance.
 
Post away. My knowledge is pretty limited in my opinion, but I'll take a look at it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top