I am a newcomer to VB 2005, and have a project working that handles events from a COM object. Strangely, simple things -like displaying a message box inside the event handling subroutine, or changing the text of an edit control- work, but others, like starting a timer or updating a progress bar inside a status strip won't. In the code below, the attempt to set the progess bar to 50 in response to eventcode 1 does nothing and generates "A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll". The DelayedAction timer in response to eventcode 0 will not execute, or -strangely- only the second time it is started??? I have checked that these will work if called from inside the form1_load sub or anywhere else as long as the event handler is not "involved".
Friend Class Form1
Public WithEvents Camera As MaxIm.CCDCamera
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Camera = CreateObject("Maxim.CCDCamera")
Camera.LinkEnabled = True
Camera.EventMask = (-1)
Exposure_ProgressBar.Value = 0
Exposure_ProgressBar.Maximum = 100
Private Sub Process_CameraEvent(ByVal CameraEventCode As Short)
Select Case CameraEventCode
Exposure_ProgressBar.Value = 50
Sequence_StatusText.Text = "Connected"
Private Sub Camera_Notify(ByVal EventCode As Short) Handles Camera.Notify
Private Sub DelayedAction_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DelayedAction.Tick
Frankly, I don't know what to do next. But something must be wrong in how I've set this up. Thanks in advance for any hints!