Homework Help - Hangman Game

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2007
Posts: 3
Reputation: terivo is an unknown quantity at this point 
Solved Threads: 0
terivo terivo is offline Offline
Newbie Poster

Homework Help - Hangman Game

 
0
  #1
May 6th, 2007
I am currently trying to program a hangman game as a final project - not a final grade or test. I have started this project but I am now stuck. The following is the code that has been started:
[
Dim
secret() AsString = {"fall", "spring", "winter", "summer", "thanksgiving"}
Dim input As Char
Dim guessWord As String
Dim randomNum As Integer
Dim wordLength As Integer
lstHidden.Items.Add(secret)
randomNum = Int(Rnd() * (secret.Length - 1))
guessWord = secret(randomNum)
wordLength = guessWord.Length
lblSecret.Text = " "
Do While wordLength > 0
lblSecret.Text = lblSecret.Text & "_ "
wordLength -= 1
Loop
input = InputBox("Enter a letter", "Letter Guess")
lstOutput.Items.Add(input)]

The problem is trying to get the users guess letter to search the secret letter and input in correct place. Can someone please help?

Thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Homework Help - Hangman Game

 
0
  #2
May 7th, 2007
There are many ways to do that. But essentially what you are trying to do is look for single characters in your secret (as you put it) word.

Using the substring method, is one way to isolate individual characters.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 3
Reputation: terivo is an unknown quantity at this point 
Solved Threads: 0
terivo terivo is offline Offline
Newbie Poster

Re: Homework Help - Hangman Game

 
0
  #3
May 7th, 2007
I know this may be basic, but I am not sure of how to do this substring. Any help on this would be appreciated. We did not cover much on substrings...just basic code.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Homework Help - Hangman Game

 
0
  #4
May 8th, 2007
Before writing any code try thinking about how you would do it in plain English...


Prompt user for a letter
Allow the system to choose a secret word
Loop through each character in word checking if it is the same as the users
If it is the same show it otherwise show a blank space


Looping through each character in a string
  1. Dim secret As String = "crap"
  2. Dim I As Integer
  3. For I = 0 to I < secret.Length - 1
  4. MsgBox(secret.substring(i,1))
  5. Next

Something like that.
Last edited by iamthwee; May 8th, 2007 at 5:25 pm.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 3
Reputation: terivo is an unknown quantity at this point 
Solved Threads: 0
terivo terivo is offline Offline
Newbie Poster

Re: Homework Help - Hangman Game

 
0
  #5
May 8th, 2007
Thanks so much.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC