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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top