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!

VB.Net & Screen.Srch Function

Status
Not open for further replies.

answers123

Technical User
May 2, 2008
33
US
Hi, I'm hoping someone can help me with this very frustrating problem.

Below is the VB.Net code where I have declared the necessary Extra! objects:

Imports EXTRA
Public Class Form2
Public Sys As EXTRA.ExtraSystem, Sess As EXTRA.ExtraSession, MyScreen As EXTRA.ExtraScreen, Srch As EXTRA.ExtraArea

I have the following code behind a button:

Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
Try
Dim TField As String
MyScreen.SendKeys("*123456<ENTER>")
MyScreen.WaitHostQuiet(2000)
Srch = MyScreen.Search("ABC")
MyScreen.WaitHostQuiet(1200)
TField = Trim(MyScreen.GetString(Srch.Bottom, Srch.Left, MyScreen.Cols - Srch.Right))
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Exclamation)
Exit Sub
End Try
End Sub

The first time I click the button the Srch Function returns the correct co-ordinates, the next time I click the button it doesn't find anything in the Srch, it's as if it's running past it too quickly.

If I put a breakpoint before, or at, the Srch line and then continue it works fine. I have played around with the WaitHostQuiet but have had not luck.

Any help would be GREATLY appreciated.
Cheers
 
Hello answers123,

Have you tried this:

Code:
[b]Set[/b] Srch = MyScreen.Search("ABC")

I believe you have to do it with the Set statement because you're assigning a value to an object, not a variable.

If you were just looking for, say, the Top coordinate, then something like

Code:
dim SrchTopLine as Integer
SrchTopLine = MyScreen.Search("ABC").top

would work.

-LB
 
Hi lmbayley,

Thanks for your reply. I am using VB Studio 2005 and in that version you don't use the Set statement, you just assign the Search to the Object to return it's coordinates.

After much frustation I finally figured out how to slow down the App for a second (or more) to wait for the host application, by using the following:

System.Threading.Thread.Sleep(1000)

Hope this helps someone else out there!

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top