Reading a Joystick with VB 6.0

Thread Starter

GS3

Joined Sep 21, 2007
408
I know close to nothing about VB but I'd like to play around and start learning. I have Win XP SP2 and VB 6.0 and an analog joystick. Just as a learning exercise and not for any aplication in particular I'd like some code which would read the joystick X, Y and 2 buttons. I found http://www.pages.drexel.edu/~kws23/tutorials/joyWin/joyWin.html which is supposed to deal with this problem but when I use the code in that page I run into problems.

The statements
- Dim ji As JOYINFOEX
- Dim caps As JOYCAPS
give the error "user defined type not defined".

joyGetPosEx gives the error "sub or function not defined", etc.

I have a feeling these are standard calls to Windows which may have been correct in older versions of Windows but may be obsolete now.

So, the question is, how can I read a joystick into VB?
 

jut

Joined Aug 25, 2007
224
It sounds to me like you're missing one of the files that came with the downloaded code.

Those variables and functions that VB is complaining about likely reside in some other file.
 
GS3,

My advice is to look into the Win32 API. There are plenty of functions relating to peripherals programming.

Additionally obtain a simple Game Development book. Choose one which has code snippets or even full programs dealing with joysticks.

As the Win32 API was written in C and most games, esspecially really professional ones are written with a combination of C, C++ and Assembly you might have to overlook the finer details of the books examples are use the book for knowleadge and as a pointer as to what functions to call etc.
Alternatively learn another language.

P.S. if you are unfamiliar with programming, this joystick business might be a start in the wrong direction.
 
Top