I am running the following code, but I'm getting an error that doesn't make much sense to me:
"Specified repeat count is not valid"
The following code works ok, but if I uncomment the For .... Next loop, it falls over on the line System.Windows.Forms.SendKeys.SendWait(strText)
Code:Private Sub btnFirstExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirstExport.Click Dim strText As String = "Some Text" & vbCr 'For x As Integer = 0 To Me.lstFirstFile.Items.Count - 1 ' strText = strText & Me.lstFirstFile.Items(x) & vbCr 'Next Dim myProcess As Process = New Process() myProcess.StartInfo.FileName = "Notepad" myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal myProcess.Start() ' wait until the program is ready for input myProcess.WaitForInputIdle(1000) If myProcess.Responding Then System.Windows.Forms.SendKeys.SendWait(strText) Else myProcess.Kill() End If End Sub




Reply With Quote