- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am having exceptions thrown that I can't figure out the problem of.
From a form, a user clicks a button to begin a sub that adds model annotation leaders one at a time.
It loops until a certain boolean is set True.
The boolean is set to True when another sub, running on a timer-tick, detects any of a few keys are pressed. The sub to add the leaders is perfectly fine and works without error, when not being looped as I am trying to do.
When I press "esc" though, I get this error:
+ $exception {"The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"} System.ArgumentException
Here's what I have:
Calling the sub:
Private Sub button_Click(sender As Object, e As EventArgs) Handles button.Click
While Trip = False 'Do the thing until the user doesn't want to do the thing anymore
AddLeader()
End While
Here's the while loop:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Integer) As Short 'Timer 'enable' and 'interval' are set in the form code where the form is instantiated Private Sub Timer1_tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim KeySpace As Boolean Dim KeyEnter As Boolean Dim KeyEsc As Boolean Dim KeyCancel As Boolean KeySpace = GetAsyncKeyState(Keys.Space) KeyEnter = GetAsyncKeyState(Keys.Enter) KeyEsc = GetAsyncKeyState(Keys.Escape) KeyCancel = GetAsyncKeyState(Keys.Cancel) If KeySpace Or KeyEnter Or KeyEsc Or KeyCancel = True Then Trip = True Else Trip = False End If End Sub
Additionally, nothing happens when I hit spacebar or enter.
Can anyone spot my mistake and give me some pointers, please?
Solved! Go to Solution.