Hello all,
I keep getting a compile error when attempting to run the following code. Does anyone know how to resolve this??
VB Code:
Dim dx As New DirectX8 Dim di As DirectInput8 Dim diDEV As DirectInputDevice8 Dim fD As DIDATAFORMAT Dim fDA(2) As DIOBJECTDATAFORMAT Dim iKeyCounter As Integer Dim aKeys(2) As String Private Sub Form_Load() Set di = dx.DirectInputCreate() If Err.Number <> 0 Then MsgBox "Error starting Direct Input, please make sure you have DirectX installed", vbApplicationModal End End If Set di = dx.DirectInputCreate() Set did = di.CreateDevice("{DE261610-ADC9-11D9-8001-444553540000}") fDA(0).lFlags = DIDOI_GUIDISUSAGE fDA(0).lOfs = 0 fDA(0).lType = DIDFT_ALIAS fDA(0).strGuid = "GUID_Button" fDA(1).lFlags = DIDOI_GUIDISUSAGE fDA(1).lOfs = 4 fDA(1).lType = DIDFT_ALIAS fDA(1).strGuid = "GUID_Button" fDA(1).lFlags = DIDOI_GUIDISUSAGE fDA(1).lOfs = 8 fDA(1).lType = DIDFT_ALIAS fDA(1).strGuid = "GUID_Button" fD.dataSize = 16 fD.lFlags = DIDFT_ALIAS fD.lObjSize = 12 fD.numObjs = 3 On Error GoTo Err did.SetDataFormat fD, fDA() '<== This is where the error occurs Me.Show diDEV.Acquire tmrKey.Interval = 10 tmrKey.Enabled = True Exit Sub Err: Dim H H = InputBox("" & Err.Number & ":" & Err.Description, , Err.Description) End Sub Private Sub Form_Unload(Cancel As Integer) diDEV.Unacquire End Sub Private Sub tmrKey_Timer() lstKeys.Clear diDEV.GetDeviceState diState For iKeyCounter = 0 To 3 If diState.Key(iKeyCounter) <> 0 Then lstKeys.AddItem KeyNames(iKeyCounter) End If Next DoEvents End Sub Function KeyNames(iNum As Integer) As String aKeys(0) = "FWD" aKeys(1) = "PLAY" aKeys(2) = "REW" KeyNames = aKeys(iNum) End Function
The Error is:
"Compile Error: only User defined types defined in public object modules can be coerced to of from a variant or passed to late-bound functions."





Reply With Quote