Thanks, Skie.
I seems that no matter how it's chopped up, the WaitForKeys method does not work in VB.Net. I had similar experience with the WaitForStrings method. Both, as it appears, work perfectly withing Extra!Basic, but not in VB.Net. And, both work fine as long as you don't assign it to anything and expect a return value.
I pasted the following code straight from the help file but, since you have to assign Wait4Keys and can't use the $, I assigned it properly to a string.
Code:
Private Sub RibbonTabItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RibbonTabItem2.Click
Dim Sys As Object, Sess As Object, MyScreen As Object
Dim Wait4Keys As String
Sys = CreateObject("EXTRA.System")
' Assumes an open session
Sess = Sys.ActiveSession
MyScreen = Sess.Screen
' Method 1: As set in TimeoutValue property,
' WaitForKeys will wait for nine seconds until
' the "a" key is pressed
Sys.TimeoutValue = 9000
Wait4Keys = MyScreen.WaitForKeys("a")
MsgBox("WaitForKeys returned " + Wait4Keys + ".")
' Method 2: As set in the Timeout parameter,
' WaitForKeys will wait for nine seconds until
' the "a" key is pressed
Wait4Keys = MyScreen.WaitForKeys(9000, "a")
MsgBox("WaitForKeys returned " + Wait4Keys + ".")
End Sub
And, I promptly get the following error message:
Conversion from type '_ComObject' to type 'String' is not valid.
No matter what the variable Wait4Keys is assigned to, an error is produced in VB.Net. It works not with a String, Object, or otherwise. Just as I stated in my third post above.
Unless someone here is successfully using this method in VB.Net, then it may well be a bug.
I feared that this would not work simply because I had the similar nightmare converting some code from Delphi to VB.Net. The WaitForString and WaitForKeys methods work perfectly in Delphi like this:
Code:
if Screen1.WaitForString('years', 21, 31) then
begin
{Add Customer Information To Record}
qryCARES.Edit;
qryCARES.FieldByName('Customer_ID').AsString := Screen1.GetString(4, 38, 9);
qryCARES.FieldByName('First_Name').AsString := Trim(Proper(Screen1.GetString(5, 12, 12)));
qryCARES.FieldByName('Last_Name').AsString := Trim(Proper(Screen1.GetString(5, 52, 12)));
qryCARES.Post;
Screen1.sendkeys('<Pf3>');
Screen1.sendkeys('<Pf3>');
end;
The above code works very well in Delphi and will wait properly for the string "years" to appear on the screen as part of a process of navigating through screens. However, there is no way that I have found to make it work in VB.Net.