Wrote this code with help of an ebook testing directx functions and all over sudden I get "Runtime Error 424 Object required", can someone tell me where am going wrong ill truly appreciate it.

Code:
Private Sub Form_Load()
'create the DirectX object
Set dx = New DirectX8
'create the Direct3D object
Set d3d = dx.Direct3DCreate()

d3dpp.hDeviceWindow = Me.hWnd
d3dpp.BackBufferCount = 1
d3dpp.BackBufferWidth = 640
d3dpp.BackBufferHeight = 480
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD
d3dpp.Windowed = 1
d3d.GetAdapterDisplayMode D3DADAPTER_DEFAULT, dispmode
d3dpp.BackBufferFormat = dispmode.Format

Set d3ddev = d3d.CreateDevice( _
D3DADAPTER_DEFAULT, _
D3DDEVTYPE_HAL, _
hWnd, _
D3DCREATE_SOFTWARE_VERTEXPROCESSING, _
d3dpp)

End Sub