Results 1 to 8 of 8

Thread: Message Boxes

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Location
    Where you live
    Posts
    104

    Message Boxes

    Hey, For my airplane game, it seems as though when the User presses the Pause key (P - which brings up a message box that is suposed to tell the user that it is paused and nothing happens until the user presses OK on it), or triggers a message box some other way, it gives me a "Run Time Error 5 - Invalid Procedue Call or Arguement"

    This only happens in the compiled form, not during testing. During testing the message boxes work properly and the pause message box does work (it halts the game until user presses OK) but not in compiled.

    VB Code:
    1. [Select Case KeyCode
    2.  
    3.     Case vbKeyP
    4.         MsgBox "Game is now paused.  Press OK to continue.", , "Game Paused"

    Thats the code used for the pause key. Whats the problem?
    Thanks.

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344
    Try:

    VB Code:
    1. If KeyCode = 80 Then
    2. MsgBox ("Paused!")
    3. Timer1.Enabled = False
    4. Select Case Msg
    5. Case ok
    6. Timer1.Enabled = True
    7. End Select
    8. End If
    Last edited by Nightwalker83; Nov 3rd, 2002 at 09:35 PM.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Location
    Where you live
    Posts
    104
    Couple questions about what you just posted Nightwalker...

    Whats the timer1 for?
    Whats the Select Case Msg and Case ok?
    Why is Text1 locked? what does that do?

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344
    Originally posted by Inno
    Couple questions about what you just posted Nightwalker...

    Whats the timer1 for?
    Whats the Select Case Msg and Case ok?
    Why is Text1 locked? what does that do?
    Put a timer and textbox on a form. Set the textbox "0" and timer1.interval = 1. Use this:

    VB Code:
    1. Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    2. If KeyCode = 80 Then
    3. MsgBox ("Paused!")
    4. Timer1.Enabled = False
    5. Select Case Msg
    6. Case ok
    7. Timer1.Enabled = True
    8. End Select
    9. End If
    10. End Sub
    11.  
    12. Private Sub Timer1_Timer()
    13. If Timer1.Interval = 1 Then
    14. Text1.Text = Text1.Text + 1
    15. End If
    16. End Sub
    Last edited by Nightwalker83; Nov 3rd, 2002 at 09:45 PM.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Location
    Where you live
    Posts
    104
    Well, that program is all fine and dandy for a program simply using a timer, but my game is not as simple as shutting off a timer. Instead of giving me code, can you (or someone else), explain to me why this error im getting is occuring. Thanks anyways Knight.

    I can send the EXE file of the game so far if anyone would like to see the problem first hand.
    Last edited by Inno; Nov 3rd, 2002 at 10:09 PM.

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Try this, as an example:

    VB Code:
    1. Select Case keycode
    2.  
    3.     Case vbKeyP
    4.         If MsgBox("Game is now paused.  Press OK to continue.", vbOKOnly, "Game Paused") = vbOK Then
    5.             'Do noting, just resume once OK pressed
    6.         End If
    7.        
    8.     'Case ????
    9.        
    10. End Select

  7. #7
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409
    the reason it does this is because when you press the run button in vb it runs your program in a simulation of the windows enviroment the vb simulation enviroment is not the same as the real windows enviroment in the simulation enviroment poing up a msgbox pauses every thing else in the windows enviroment it does not

    so to fix your problem you will have to stop the code from running to do this make a global varible called Paused as boolean (u can name it what ever you want) and when they do the thing that pauses the game set it to true and when they unpause it set it to false

    then where ever you need code to not run when the game is paused say

    if paused = false
    'code to run
    end if

    so now when the game is paused any code that you dont want to run any more want

    hope this helps

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Location
    Where you live
    Posts
    104
    Ok, Seems im getting the same error "Run Time error 5 - Invalid procedure call or arguement" for an input box when you press ESC.

    This code produces that error:

    VB Code:
    1. Do Until Len(UserName) >= 1 And Not IsNumeric(UserName) And Not Len(UserName) >= 9
    2. UserName = InputBox(Msg, "Aero-Plane Challenge", "No Name")
    3. Falling.Enabled = True
    4. Timer3.Enabled = True
    5. CrashWatch.Enabled = True
    6. Pointstimer.Enabled = True
    7. Loop

    However, take away the 1st line and the last line (the loops statement), and no more error! Perhaps the same problem for the message boxes are arising? Thx for ne help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width