|
-
Apr 18th, 2005, 12:21 PM
#1
Thread Starter
Lively Member
Direct X Error [Resolved]
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."
Last edited by Xman51; Apr 18th, 2005 at 02:32 PM.
Reason: resolved
-
Apr 18th, 2005, 12:49 PM
#2
Thread Starter
Lively Member
Re: Direct X Error
Ok, I figured out that one which was my mistake. I was calling an unnamed variable "did" instead of "diDEV". However, it still gives me an error on the same line. This time the error is:
Run-Time error '5'; invalid procedure call or argument.
HELP!!!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|