Direct Input8 error 91

Sfpiano
07-27-2002, 04:16 PM
Error 91:
Set DI = DX.DirectInputCreate()

(located in the CreateDI(hWnd As Long) function in the functions module)

Iceplug
07-27-2002, 04:22 PM
Did you define
DX As DirectX8
DI As DirectInput8

Set DX = New DirectX8? :)

Squirm
07-27-2002, 04:38 PM
As Iceplug said, every object you declare, must be instatiated before it can be used.

'Declare the objects
Dim DX As DirectX8
Dim DI As DirectInput8

'Now, they must be instantiated before use
Set DX = New DirectX8
Set DI = DX.DirectInputCreate

Sfpiano
07-27-2002, 04:42 PM
Yeah, I did that this time, still doesn't work

Squirm
07-27-2002, 05:38 PM
Well, since I can't open .ace files I can't see your code. I think .zip would be more useful, as per your previous thread.

:)

Sfpiano
07-27-2002, 06:09 PM
Sorry about that, I'll make a note

Iceplug
07-27-2002, 06:15 PM
You must create a new DirectX8 object before doing anything with DirectX8.

In your code, you have:
Private Sub Form_Load()

Me.Show '//Must come in beginning
CreateDI frmMain.hWnd
With Camera
.CamX = 0: .CamY = 10: .CamZ = 0: .XZAngle = 0: .XYAngle = 0
.LookX = 0: .LookY = 10: .LookZ = -1
End With
Camera.XZAngle = 90
Camera.LookX = 0 + Cos(90 * Rad)
Camera.LookZ = 0 - Sin(90 * Rad)

bRunning = Initialise()

And DX is not set until Initialise().
You must Set DX = New DirectX8 first.

Squirm
07-27-2002, 06:18 PM
Your problem is that you're initialising the DX object inside the Initialise sub (which inits D3D), but you're calling CreateDI before that, so the DX object has not been initialised at that point.

Set DX = New DirectX8

Move the above line from the Initialise sub into the CreateDI sub, or add this line:

If DX Is Nothing Then Set DX = New DirectX8

:)

Sfpiano
07-27-2002, 06:53 PM
thanks

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum