Does VB.NET have the equivalent of the Excel/Word EnableCancelKey without using DoEvents?

  • Thread starter Thread starter Howard Kaikow
  • Start date Start date
H

Howard Kaikow

If one has code that cannot include DoEvents, is it possible to achieve the
equivalent of either of the following Excel VBA codes in VB .NET?

Public Sub EnableInterrupt1()
Const User_Interrupt_Occurred As Long = 18
Application.EnableCancelKey = xlErrorHandler
On Error GoTo FinishUp
Do
' Code that cannot include DoEvents
Loop
FinishUp:
Select Case Err.Number
Case 0
' Do something
Case User_Interrupt_Occurred
' Do something else
Case Else
With Err
MsgBox .Description, vbInformation + vbCritical, "Error: " &
..Number
End With
End Select
End Sub

Public Sub EnableInterrupt2()
Application.EnableCancelKey = xlInterrupt
Do
' Code that cannot include DoEvents
Loop
End Sub
 
Back
Top