|
-
Nov 3rd, 2002, 08:55 PM
#1
Thread Starter
Lively Member
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:
[Select Case KeyCode
Case vbKeyP
MsgBox "Game is now paused. Press OK to continue.", , "Game Paused"
Thats the code used for the pause key. Whats the problem?
Thanks.
-
Nov 3rd, 2002, 09:28 PM
#2
Try:
VB Code:
If KeyCode = 80 Then
MsgBox ("Paused!")
Timer1.Enabled = False
Select Case Msg
Case ok
Timer1.Enabled = True
End Select
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
-
Nov 3rd, 2002, 09:37 PM
#3
Thread Starter
Lively Member
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?
-
Nov 3rd, 2002, 09:39 PM
#4
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:
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 80 Then
MsgBox ("Paused!")
Timer1.Enabled = False
Select Case Msg
Case ok
Timer1.Enabled = True
End Select
End If
End Sub
Private Sub Timer1_Timer()
If Timer1.Interval = 1 Then
Text1.Text = Text1.Text + 1
End If
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
-
Nov 3rd, 2002, 10:06 PM
#5
Thread Starter
Lively Member
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.
-
Nov 3rd, 2002, 10:15 PM
#6
Try this, as an example:
VB Code:
Select Case keycode
Case vbKeyP
If MsgBox("Game is now paused. Press OK to continue.", vbOKOnly, "Game Paused") = vbOK Then
'Do noting, just resume once OK pressed
End If
'Case ????
End Select
-
Nov 3rd, 2002, 10:52 PM
#7
Hyperactive Member
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
-
Nov 5th, 2002, 05:38 PM
#8
Thread Starter
Lively Member
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:
Do Until Len(UserName) >= 1 And Not IsNumeric(UserName) And Not Len(UserName) >= 9
UserName = InputBox(Msg, "Aero-Plane Challenge", "No Name")
Falling.Enabled = True
Timer3.Enabled = True
CrashWatch.Enabled = True
Pointstimer.Enabled = True
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|