hangman
hangman
hangman
hangman
hangman
hangman hangman hangman hangman hangman hangman hangman hangman
hangman hangman
hangman
Go Back  Xtreme Visual Basic Talk > > > hangman


Reply
 
Thread Tools Display Modes
  #1  
Old 06-16-2009, 11:57 AM
clearvision clearvision is offline
Newcomer
 
Join Date: Mar 2009
Posts: 6
Default hangman


Code:
Private intpart As Integer Private blnfound As Boolean Private strLetter1 As String Private strLetter2 As String Private strLetter3 As String Private strLetter4 As String Private strLetter5 As String Private Sub cmdDone_Click() Unload Me End Sub Private Sub cmdPlayGame_Click() blnfound = False Const strSentinel As String = "!" Dim strSecretWord As String, intSecretWordLength As Integer Dim intNumberOfGuesses As Integer Dim strGuess As String, strWordGuessedSoFar As String Dim intLetterPos As Integer strSecretWord = "magic" intSecretWordLength = Len(strSecretWord) strWordGuessedSoFar = String(intSecretWordLength, "_") intNumberOfGuesses = 0 strGuess = InputBox("Guess a letter(! to guess word)", "Hangman") Do While strGuess <> strSentinel intNumberOfGuesses = intNumberOfGuesses + 1 For intLetterPos = 1 To intSecretWordLength If StrComp(strGuess, Mid(strSecretWord, intLetterPos, 1), vbTextCompare) = 0 Then lblletter.Visible = True End If Next intLetterPos strGuess = InputBox("Guess a letter (! to guess word)", "Hangman") Loop If strGuess = strSentinel Then strGuess = InputBox("Guess the Word") End If If StrComp(strGuess, strSecretWord, vbTextCompare) = 0 Then MsgBox "You win! It took you " & intNumberOfGuesses & "guesses." End If If strGuess = strLetter1 Then lblletter(0).Visible = True blnfound = True End If If strGuess = strLetter2 Then lblletter(1).Visible = True blnfound = True End If If strGuess = strLetter2 Then lblletter(2).Visible = True blnfound = True End If If strGuess = strLetter2 Then lblletter(3).Visible = True blnfound = True End If If strGuess = strLetter2 Then lblletter(4).Visible = True blnfound = True End If If blnfound = False Then ShpPerson(intpart).Visible = True intpart = intpart + 1 End If If strGuess <> blnfound Then ShpPerson(intpart).Visible = True intpart = intpart + 1 End If End Sub Private Sub Form_Load() intpart = 0 strLetter1 = "m" strLetter2 = "a" strLetter3 = "g" strLetter4 = "i" strLetter5 = "c" ShpPerson(0).Visible = False ShpPerson(1).Visible = False ShpPerson(2).Visible = False ShpPerson(3).Visible = False ShpPerson(4).Visible = False ShpPerson(5).Visible = False End Sub

i have it right so far so when u guess a letter the letter will appear. But i need help having shapes appear at a time each time i get a letter wrong ..i created a control array of shapes on the program

this is where i try to get a shape appear each time i guess wrong..but i cant figure out how to do it

If strGuess <> blnfound Then
ShpPerson(intpart).Visible = True
intpart = intpart + 1
End If

Last edited by passel; 06-19-2009 at 06:43 PM. Reason: Added vb /vb tags
Reply With Quote
  #2  
Old 06-16-2009, 07:50 PM
vb5prgrmrhangman vb5prgrmr is offline
Senior Contributor

* Expert *
 
Join Date: Mar 2009
Posts: 1,087
Default

If String <> Boolean Then????

Okay, I have a lot of things to say but will try to sum it up with one function that you can look up in VB's Help Files

Instr

and then I will say that when you check to see if the letter guessed is correct then you should set your variable (psudo)...

False
Letter guessed is part of word then
true
else
do nothing
if false then
show shape
else
do nothing'guess was correct

Good Luck
Reply With Quote
  #3  
Old 06-16-2009, 08:29 PM
clearvision clearvision is offline
Newcomer
 
Join Date: Mar 2009
Posts: 6
Default

^ so should be sumthin like this?

If strGuess = False Then
ShpPerson(intpart).Visible = True
intpart = intpart + 1
End If
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
hangman
hangman
hangman hangman
hangman
hangman
hangman hangman hangman hangman hangman hangman hangman
hangman
hangman
 
hangman
hangman
 
-->