?hm ... somehow silly question (Error in VB6 and DX7) 
Author Message
 ?hm ... somehow silly question (Error in VB6 and DX7)

Hi folks,

I am trying to implement some sort of "command-pipeline" to a small desktop
game of  mine.

Every time, the user presses a key, the DXEvent is supposed to pass a
game-command to the end of a dynamic array, after expanding the array by one
item. (The AddCommand sub is located in my GameClass).

And every time i finished executing one game command, the main loop should
get the next command ... from the beginning of the "pipeline". (Of Course,
the GetNextCommand function is in the GameClass as well.)

But I seem not to get the syntax right.

Can anybody help me?

Here is the code:

'GameClass_________________________________________

    Dim myCommandQueue() As GameCommand

'__________________________________________________
Public Sub AddCommand(Command As GameCommand)
    Dim TempQueueIndex As Long

    TempQueueIndex = UBound(myCommandQueue) + 1
         'This is where the error occurs:
         'Runtime Error 9: Index out of valid range
        '(This is a rough translation from the german VB 6)
    ReDim Preserve myCommandQueue(0 To TempQueueIndex) As GameCommand
    myCommandQueue(TempQueueIndex) = Command

    Debug.Print "AddCommand: " & Command
End Sub

'___________________________________________________

Public Function GetNextCommand() As GameCommand
    Dim TempQueueIndex As Long

    TempQueueIndex = UBound(myCommandQueue) - 1
    GetNextCommand = myCommandQueue(0)
    ReDim Preserve myCommandQueue(0 To TempQueueIndex)

    Debug.Print "GetNextCommand: " & myCommandQueue(0)
End Function

--

Greetings out of {*filter*}space,
Mondspeer




Thu, 30 Dec 2004 00:18:12 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Silly question or silly compiler ?

2. Colors in DX7 and VB6

3. AVI using DX7 in VB6 (please help)

4. AVI using DX7 in VB6 (please help)

5. Dx7 RM SetOrientation Question

6. DX7 and VB and automation error

7. silly question: how to show a form

8. Silly ArrayList Question

9. really silly question on "Builds"

10. VB.net silly tabcontrol questions

11. Just a silly question

12. Some Silly Questions

 

 
Powered by phpBB® Forum Software