Results 1 to 2 of 2

Thread: Direct X Error [Resolved]

  1. #1

    Thread Starter
    Lively Member Xman51's Avatar
    Join Date
    Mar 2005
    Location
    Tampa, FL USA
    Posts
    88

    Resolved 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:
    1. Dim dx As New DirectX8
    2. Dim di As DirectInput8
    3. Dim diDEV As DirectInputDevice8
    4.  
    5. Dim fD As DIDATAFORMAT
    6. Dim fDA(2) As DIOBJECTDATAFORMAT
    7. Dim iKeyCounter As Integer
    8. Dim aKeys(2) As String
    9.  
    10.  
    11. Private Sub Form_Load()
    12.  
    13.  
    14.     Set di = dx.DirectInputCreate()
    15.        
    16.     If Err.Number <> 0 Then
    17.         MsgBox "Error starting Direct Input, please make sure you have DirectX installed", vbApplicationModal
    18.         End
    19.     End If
    20.        
    21.        
    22.     Set di = dx.DirectInputCreate()
    23.  
    24.     Set did = di.CreateDevice("{DE261610-ADC9-11D9-8001-444553540000}")
    25.  
    26.     fDA(0).lFlags = DIDOI_GUIDISUSAGE
    27.     fDA(0).lOfs = 0
    28.     fDA(0).lType = DIDFT_ALIAS
    29.     fDA(0).strGuid = "GUID_Button"
    30.  
    31.     fDA(1).lFlags = DIDOI_GUIDISUSAGE
    32.     fDA(1).lOfs = 4
    33.     fDA(1).lType = DIDFT_ALIAS
    34.     fDA(1).strGuid = "GUID_Button"
    35.  
    36.     fDA(1).lFlags = DIDOI_GUIDISUSAGE
    37.     fDA(1).lOfs = 8
    38.     fDA(1).lType = DIDFT_ALIAS
    39.     fDA(1).strGuid = "GUID_Button"
    40.    
    41.    
    42.     fD.dataSize = 16
    43.     fD.lFlags = DIDFT_ALIAS
    44.     fD.lObjSize = 12
    45.     fD.numObjs = 3
    46.  On Error GoTo Err
    47.     did.SetDataFormat fD, fDA() '<== This is where the error occurs
    48.  
    49.  
    50.     Me.Show
    51.    
    52.     diDEV.Acquire
    53.        
    54.     tmrKey.Interval = 10
    55.     tmrKey.Enabled = True
    56. Exit Sub
    57.  
    58. Err:
    59. Dim H
    60. H = InputBox("" & Err.Number & ":" & Err.Description, , Err.Description)
    61.  
    62.  
    63. End Sub
    64.  
    65. Private Sub Form_Unload(Cancel As Integer)
    66.     diDEV.Unacquire
    67. End Sub
    68.  
    69. Private Sub tmrKey_Timer()
    70.     lstKeys.Clear
    71.    
    72.     diDEV.GetDeviceState diState
    73.    
    74.     For iKeyCounter = 0 To 3
    75.         If diState.Key(iKeyCounter) <> 0 Then
    76.             lstKeys.AddItem KeyNames(iKeyCounter)
    77.         End If
    78.     Next
    79.     DoEvents
    80. End Sub
    81.  
    82. Function KeyNames(iNum As Integer) As String
    83.  
    84.     aKeys(0) = "FWD"
    85.     aKeys(1) = "PLAY"
    86.     aKeys(2) = "REW"
    87.  
    88.     KeyNames = aKeys(iNum)
    89.  
    90. 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
    Xman51
    Area 51


  2. #2

    Thread Starter
    Lively Member Xman51's Avatar
    Join Date
    Mar 2005
    Location
    Tampa, FL USA
    Posts
    88

    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!!!!!
    Xman51
    Area 51


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width