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!

Wait for Text anywhere on mainframe (need VBA)

Status
Not open for further replies.

rib742

Programmer
Jun 7, 2003
28
US
I'm converting some mainframe VBscript macros to VBA and can't seem to figure a piece out.

In VBScript I use the EMWaitText where I look for a string anywhere on the screen to get it's X coordinate. The Y coordinate is always a constant.

EMWaitText .15,strTextLoc,1,1,intRowResult, intColResult
If intColResult >0 Then
strTextLoc = intRowResult
End If

I have a function (below) to wait for a string when I know the X,Y coordinates it should be at but can't seem to modify it accomodate what I need above.

Public Sub WaitText(ctl As Control, strText As String, lngX As Long, lngY As Long, Optional blnDoEnter As Boolean = False)

Dim strRetVal As String

ctl.GetScreen strRetVal, lngX, lngY, Len(strText)

Do Until strRetVal = strText
ctl.GetScreen strRetVal, lngX, lngY, Len(strText)

DoEvents

If blnDoEnter = True Then
DoEnter (ctrl)
End If
Loop
End Sub

Any assistance is appreciated.
 
Figured it out for my project.

Public Sub WaitTextLoc(ctrl As Control, strText As String, X As Long, Y As Long, Optional blnDoEnter As Boolean = False)

Dim strRetVal As String

ctrl.GetScreen strRetVal, X, Y, Len(strText)

Do Until strRetVal = strText
ctrl.GetScreen strRetVal, X, Y, Len(strText)

DoEvents

If blnDoEnter = True Then
DoEnter (ctrl)
End If

If X = 25 Then
Exit Sub
End If

If strRetVal = strText Then
Y = Len(strText) + 2
Exit Do
End If

X = X + 1

Loop

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top