Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Why doesn't this statement work?
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
cwlvc




PostPosted: Wed Jun 11, 2008 7:25 pm   Post subject: Why doesn't this statement work?

ok, so i had this other thread, but after 35 views, there was NO reply, so i had to figure out myself, even though it took a long time. but now that i've figured out, there's a small problem. for a hangman game, when there's 2 mistakes, the head comes on, after 3 mistakes, the left arm comes on, but i want it after one mistake, the head comes on, after 2 mistakes, the left arm comes on. this is my coding.

Option Explicit
Private Const strWord As String = "water"
Private Const strWordTwo As String = "cross"
Private Const StrWordThree As String = "spark"
Private Const strWordFourth As String = "minus"
Private intNumber As Integer
Private strText As String
Private intWrong As Integer

Private Sub Form_Load()
Randomize
intNumber = Int(4 * Rnd + 1)

intWrong = 0

End Sub


Private Sub cmdA_Click()
If intWrong = 1 Then
shpHead.Visible = True
ElseIf intWrong = 2 Then
lneBody.Visible = True
ElseIf intWrong = 3 Then
lnelefthand.Visible = True
ElseIf intWrong = 4 Then
lnerighthand.Visible = True
ElseIf intWrong = 5 Then
lneleftleg.Visible = True
ElseIf intWrong = 6 Then
lnerightleg.Visible = True
End If

If intNumber = 1 Then
lbl2.Caption = "a"
ElseIf intNumber = 2 Then
lblmessage.Caption = "guess Again"
ElseIf intNumber = 3 Then
lbl3.Caption = "a"
ElseIf intNumber = 4 Then
lblmessage.Caption = "guess again"
End If
cmdA.Visible = False

If intNumber = 2 Or intNumber = 4 Then
intWrong = intWrong + 1
lblCount = intWrong

End If
End Sub
Private Sub cmdB_Click()

If intWrong = 1 Then
shpHead.Visible = True
ElseIf intWrong = 2 Then
lneBody.Visible = True
ElseIf intWrong = 3 Then
lnelefthand.Visible = True
ElseIf intWrong = 4 Then
lnerighthand.Visible = True
ElseIf intWrong = 5 Then
lneleftleg.Visible = True
ElseIf intWrong = 6 Then
lnerightleg.Visible = True
End If

If intNumber = 1 Then
lblmessage.Caption = "guess again"

ElseIf intNumber = 2 Then
lblmessage.Caption = "guess again"

ElseIf intNumber = 3 Then
lblmessage.Caption = "guess again"

ElseIf intNumber = 4 Then
lblmessage.Caption = "guess again"

End If
cmdB.Visible = False

If intNumber = 1 Or intNumber = 2 Or intNumber = 3 Or intNumber = 4 Then
intWrong = intWrong + 1
lblCount = intWrong
End If
End Sub




i only gave you "A" and "B", but the rest of the code are the same...
Sponsor
Sponsor
Sponsor
sponsor
lordroba




PostPosted: Wed Jun 11, 2008 7:37 pm   Post subject: Re: Why doesn't this statement work?

this sounds a bit counter intuitive, but try changing

intWrong = 0

to

intWrong = 1

you're only off by one mistake, so this might be the easiest way to fix the problem.
cwlvc




PostPosted: Thu Jun 12, 2008 11:10 am   Post subject: RE:Why doesn\'t this statement work?

yea, but after i change it to 1, then the head appears before i even make an mistake.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: