Dear All,

I am using VB Express 2008, on Windows XP Pro. I have written a programme which tests another programme which compares prices and terms from several vendors. This Bid Tabulation programme, compares prices and terms of up to 10 Bidders and 500 line items in mixed currencies.

The testing programme, initially, would not work and I discovered that I needed to introduce a delay in order for it to run the Bid Tabulation programme. So my initial code, using the delay, was:

Code:
Process.Start("E:\NewFiles\BidTab\BidTab\bin\Release\BidTab.exe")
          
          TimeDelay()
          
          ParentHWND = FindWindow("WindowsForms10.Window.8.app.0.378734a", "Bid Tab Main Programme")
          If ParentHWND <> IntPtr.Zero Then
               ChildHWND = FindWindowEx(ParentHWND, IntPtr.Zero, "WindowsForms10.BUTTON.app.0.378734a", "Enter")
               For x = 1 To 3
                    ChildHWND = FindWindowEx(ParentHWND, ChildHWND, "WindowsForms10.BUTTON.app.0.378734a", "Enter")
               Next
               PostMessage(ChildHWND, BM_CLICK, 0, 0)
          End If
And the button was clicked, and the Bid Tabulation programme started and ran successfully, as long as the number of vendors was 5 and the number of line items was 5. when I tried to increase the number of vendors to 10, the programme failed.

I then discovered that at the point of failure, when the particular ParentHWND=0, if I introduced:

Code:
For i = 1 To 10
TimeDelay()
Next
It worked again. However, when I tried to run 10 vendors and 30 line items, once more it failed. I could increase the numbers slightly by modifying the time delays, but even when I went to:

Code:
For i = 1 To 40
TimeDelay()
Next
I still could not get the programme to successfully run.

TimeDelay() is a simple:

Code:
Private Sub TimeDelay()

          For x = 1 To 10000
               For y = 1 To 10000

               Next
          Next

End Sub
Does anyone know what I am doing wrong, or whether there is another way to assure that ParentHWND will not equal zero without using a time delay?

Regards,

john