Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi world,
I have been working on a game and I have come across this error - "RunTime Error "424" Object Required".
I understand what it means and how to fix it however I have been trying to figure it out for literally hours and i'm stumped.
Code:Private Sub Label5_Click()
If RIFLE.blnACTIVE = False Then
If Money >= 1500 Then
Money = Money - 1500
RIFLE.blnACTIVE = True
Label5.Caption = "$3000 - Upgrade Rifle"
Form1.Option2.Enabled = True
End If
ElseIf RIFLE.blnACTIVE = True And RIFLE.sngLEVEL < 6 Then
If Money >= (6000 * (RIFLE.sngLEVEL / 2)) Then
Money = Money - (6000 * (RIFLE.sngLEVEL / 2))
RIFLE.sngLEVEL = RIFLE.sngLEVEL + 1
End If
ElseIf RIFLE.snglvl = 5 Then
MsgBox "Sorry, But your Rifle is at it's maximum level", vbOKOnly, "Zombie Defence"
Else
MsgBox "Sorry, You have insufficent funds", vbOKOnly, "Zombie Defence"
End If
End SubCode:
The error points to the line which is in italics.
I do have a module which may have somthing to do with it...
Code:Public Type GUNTYPE
blnACTIVE As Boolean
blnAUTO As Boolean
sngDAMAGE As Single
sngRELOADTIME As Single
sngFIRERATE As Single
sngCOST As Single
sngAMMO As Single
sngLEVEL As Single
End TypeCode:
money is also dimentionalised and form1.option2 does exist.

I find this Hungarian style grating. When you've got Intellisense built into your IDE there's not much use in making your code illegible by prefixing your names with unpronounceable characters.
If RIFLE.blnACTIVE = False Then
>>> If Not Rifle.Active ThenElseIf RIFLE.blnACTIVE = True And RIFLE.sngLEVEL < 6 Then
>>> ElseIf Rifle.Active And Rifle.Level < 6 ThenAlso why is Level a Single when it could be an Integer? And you've got RIFLE.snglvl near the end, which is mistyped.

klint: I find this Hungarian style grating.
Meh, it's what Microsoft harped on in the VB6 age. I do find Systems Hungarian notation to be pointless at best. MS agrees.[I]f you write convoluted, dense academic prose nobody will understand it . . . and then the misinterpreted ideas will be ridiculed. -- Joel Spolsky

lols, thanks.
I cant believe I forgot that, I works now.
The only problem with the part im doing now is that I have to finnish a round before it comes up, im already bored of my own game. :(
for the sake of testing I wont change it temporarily.
I also changed it to an integer. all the others are singles because in the equasion that determines that value, at some point will cause a decimal.
If you want just e-mail me if you want a copy, its not finnished but its really close.

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |