|
|
How do you program Hangman in VB 2008, word length problem?How do I program hangman with out exact letter lengths? I can get the program to work by using an exact length of words, but in this instance I need it to program UP TO a maximum of 10 letters, so it could be a 5 letter word or a 3 letter word or a 7 letter word and I don't know how to program it that way. I'm no where near a programmer and this is my first class that I have taken with programming. I have struggled with this class the whole time I have been in it and the book we have doesn't give the best examples or describe things in depth very well. How do I make this game work with a maximum of 10 letters? Show us some of your code. I think I am following you, but you didn't really give enough detail about your requirements or how you are implementing it as of now. Why is the maximum of 10 letters a problem for you? Give a bit more info and I know I can help.
Edit: 'get a 10-letter work from player 1, convert to uppercase strWord = InputBox("Enter a 10-letter word:", _ "Hangman Game").ToUpper------------> That is correct. 'determine whether the word contains 10 letters blnValidWord = True 'assume the word is valid----->That is fine. If strWord.Length <> 10 Then ----->You are stating that you will only allow a number that is 10 characters long. What you want is a MAX of 10 characters. So heres what you should do: If strWord.Length >10 Then ------> if strWord is greater than 10 characters, then blnValidWord is false blnValidWord = False Else Dim intIndex As Integer ---> Dim all variables at the beginning of your subprocedure, not in the middle like this. Do While intIndex < 10 And(--->"Also" should not be used) blnValidWord = True If strWord.Substring(intIndex, 1) Like "[A-Z]" Then blnValidWord = False -----> Wouldn't you want this to be true if the string contains characters [A-Z]? End If intIndex = intIndex + 1 ----> Could also use intIndex += 1 Loop End If 'if the word is not valid, display a message If blnValidWord = False Then MessageBox.Show("10 letters are required.", _ "Hangman Game", MessageBoxButtons.OK, _ MessageBoxIcon.Information) ----> You could just use MsgBox("your text") in this instance. As another tip, I would put the letters in an array while you are evaluating their validity if you plan to make a functional hangman game. Arrays would make this quite simple. I did not point out all of the problems since it seems you are trying to learn VB, so let's see if you can finish it from here. If you have more questions, feel free to ask me. Where can i find an online HANGMAN game for my 6 year old son with easy words?I found a site today that i thought was suitable but the first word was ejaculation...i don't think very suitable forWhat are easy games like Tic-tac-toe and hangman? (I just need like 5 games, cards, pencil and paper)?OK.The question is simple ^^ So the more games (that young kids can play, and it's easy to explain) you Using the program visual express edition 2008 can I design spectrum zx programs? like hangman?hi, I used to design little programs on the spectrum zx like hangmanand i was wondering is it possible to design them Where can I find a free online challenging hangman game with multiple genres?I am looking for a free online hangman games with genres such as pop trivia, music, celebs, tv&movies, or stuff likeWhat are good hangman words?any difficult to think of, but that are easy to remember.(eg. czar, cyst, pygmy... etc) Hangman word i cant figure out! HELP?The word isEdge_a_s the avaliable letters are : F H J K P Q U W X Y Z So out of those letters could Argh, visual basic express ed. 2008, hangman won't work! says that 'Index was out of range. Must be non-neg'?When user has input too many wrong goes it crashes and comes up yellow at the line 'index = thisword.word.IndexOf(letter, |
|