-
ActiveX exe problem.
My First ActiveX exe:
Class1:
Code:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Form As Form
Public Cancel As Boolean
Public Sub go()
Form.text1.Text = 1
Do Until Cancel = True
Sleep 1000
Form.text1.Text = Form.text1.Text + 1
Loop
End Sub
In another Project:
Form1
Code:
Dim This As New Class1
Private Sub Command1_Click()
Set This.Form = Form1
This.go
End Sub
Private Sub Command2_Click()
This.Cancel = True
End Sub
When I run this, the number in the textbox increses by one every second. But when i try to click on Command2 I get:
Component Request Pending
An action cannot be completed because a
component (qwe) in not responding. Choose
"Swith To" to activate the component and correct
the problem.
How can I fix this?
-
Append to your code as followed:
Code:
'class
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Form As Form
Public Cancel As Boolean
Public Sub go()
Form.Text1.Text = 1
Do Until Cancel = True
DoEvents 'added this line to your code
Sleep 1000
Form.Text1.Text = Val(Form.Text1.Text) + 1 'avoid type mismatch error
Loop
End Sub