I am trying to create a subroutine that when called will have a countdown timer and an OK button. I have the script created using the internetexplorer.application method but when I try to put the code into a subroutine my check for the OK button to be clicked no longer works. Does anybody know why? or a different way to check for the ok button to be clicked? Here is my code
Thanks
Dan
Code:
passint = 10
Const READYSTATE_COMPLETE = 4
Set ie = CreateObject ("InternetExplorer.Application")
ie.navigate "about:blank"
ie.toolbar = 0
ie.MenuBar = 0
ie.statusbar = 0
ie.width = 250
ie.height = 250
ie.left = 0
ie.top = 0
Do While ie.ReadyState <> READYSTATE_COMPLETE
WScript.Sleep 50
Loop
ie.visible = True
Dim text
Set text = ie.document.createElement("textarea")
loopcnt = passint - 1
text.Value = passint
ie.document.body.AppendChild text
Dim okButton
Set okButton = ie.document.createElement("input")
okButton.type = "button"
okButton.value = "OK"
ie.document.body.AppendChild okButton
Dim Finished: Finished = False
Set okButton.onclick = GetRef("OK_Clicked")
For I = 0 To loopcnt
WScript.sleep 1000
passint = passint - 1
text.Value = passint
If finished = True Then i = loopcnt
Next
finished = True
Do While Not Finished
WScript.Sleep 50
Loop
WScript.Echo text.value
ie.Quit
Sub OK_Clicked()
Finished = True
End Sub
Thanks
Dan