| | |
Homework Help - Hangman Game
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2007
Posts: 3
Reputation:
Solved Threads: 0
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
[
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
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
Something like that.
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
VB.NET Syntax (Toggle Plain Text)
Dim secret As String = "crap" Dim I As Integer For I = 0 to I < secret.Length - 1 MsgBox(secret.substring(i,1)) Next
Something like that.
Last edited by iamthwee; May 8th, 2007 at 5:25 pm.
*Voted best profile in the world*
![]() |
Similar Threads
- Writing a Hangman game (C++)
- Hangman Game Help!! (Java)
- Hangman project (VB.NET)
- hangman revised (VB.NET)
- Need help with a certain part to a hangman game.. (Visual Basic 4 / 5 / 6)
- Can u help me with hangman code in vb.net please :( (VB.NET)
Other Threads in the VB.NET Forum
- Previous Thread: List View save data from it to mysql
- Next Thread: unable to connect
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2008 access advanced application array basic beginner browser button buttons center click client code combo convert cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic eclipse excel exists fade filter forms function html images input lib listview map mobile module monitor msaccess net number objects open panel pdf picturebox picturebox2 port position print printing problem read regex remove right-to-left save search serial settings shutdown socket sorting sqldatbase sqlserver survey temperature textbox timer timespan transparency txttoxmlconverter user usercontol validation vb vb.net vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web webbrowser winforms winsock wpf wrapingcode xml year






