I am attempting to use the COM API from within VB 6. I am able to access the Device, Sensor, and Keyboard objects, but am not able to handle events. Here is my simple test program:
Code: Select all
Option Explicit
Private WithEvents Device As TDxInput.Device
Private WithEvents Sensor As TDxInput.Sensor
Private WithEvents Keyboard As TDxInput.Keyboard
Private Sub Form_Load()
Set Device = New TDxInput.Device
Set Sensor = Device.Sensor
Set Keyboard = Device.Keyboard
LabelStatus = "Connecting..."
Device.Connect
If Device.IsConnected Then
If Device.Type = 0 Then
LabelStatus = "connected but type unknown"
Device.Disconnect
Else
LabelStatus = "connected! - type = " & Device.Type & ", keys = " & Keyboard.Keys
End If
Else
LabelStatus = "not connected"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Device.IsConnected Then
Device.Disconnect
End If
Set Device = Nothing
End Sub
Private Sub Sensor_SensorInput()
LabelStatus = "sensor input!"
End Sub
PS replies of the form "why are you using VB 6" will not be helpful