Reading a Joystick with VB 6.0

Discussion in 'Programmer's Corner' started by GS3, Sep 24, 2007.

  1. GS3

    Thread Starter Senior Member

    Sep 21, 2007
    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 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?
  2. jut

    Senior Member

    Aug 25, 2007
    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.
  3. Developer_Dan()


    Oct 8, 2007

    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.
  4. Developer_Dan()


    Oct 8, 2007
    Hi again,

    Also try to download Microsoft XNA Game Studio Express.

    Should be some examples and things to help you.
    Also a lot easier than using Win32 API and OpenGL/DirectX to develop games directly.