I ran into a couple issues with my hangman program I'm working on for class,
If anyone wouldn't mind helping me post here...
http://rafb.net/p/s7R8bI96.html
is the code for that whole class
Problem #1
^ picHangman = Image.FromFile(strFileName & ".jpg")
I want to call for each enum, 1-9 jpg are the images of the hangman body
HEAD, HEAD+NECK, etc.
It says strFileName, isn't declared. Yea I know declare it but how do I get it do go through 9
Problem #2
I commented most of that out, so ignore the comments
TryALetter is a sub that accepts a character. It finds all occurrences of the guessed letter
in mWord and changes the “*”’s at the same location in mUncoveredLetter to the actual letter. (A useful method to use is .IndexOf, for example, mWord.IndexOf(chrGuessLetter) returns the location of the character in the string. If a negative number is returned, the letter is not in the string.) If the letter is in the word, then you need to “uncover” it in mUncoveredWord. One way to do this is to create an array of characters and assign mUncoveredLetters to that array.
That way you can loop through comparing each character in mWord (mWord.Chars(i)) to the guess letter and if it matches assign the letter to the same location in your UncoveredLetters array. Once you have processed the entire word, set mUncoveredLetters equal to the array in order to transfer the new set of letters back to the mUncoveredLetters variable. If the letter is not in your word at all, your program should increment HangmanImage by 1.
If anyone wouldn't mind helping me post here...
http://rafb.net/p/s7R8bI96.html
is the code for that whole class
Problem #1
Code:
Public Enum HANGMAN_STATUS As Short HEAD = 1 picHangman = Image.FromFile(strFileName & ".jpg") NECK = 2 BODY = 3 LEFT_ARM = 4 RIGHT_ARM = 5 LEFT_LEG = 6 RIGHT_LEG = 7 LEFT_FOOT = 8 HUNG = 9 End Enum
I want to call for each enum, 1-9 jpg are the images of the hangman body
HEAD, HEAD+NECK, etc.
It says strFileName, isn't declared. Yea I know declare it but how do I get it do go through 9
Problem #2
Code:
Public Sub TryALetter(ByVal chrGuessLetter As Char) Dim mWordChar 'character of the word to check Dim i As Short Dim ModifiedWordArray As Char() = New Char(26) {} ' If mOriginalWord.IndexOf("Q") >= 0 Then 'If mWord.IndexOf(chrGuessLetter) >= 0 Then ' mUncoveredLetters = mWord.IndexOf(chrGuessLetter) ' ModifiedWordArray = mWord ' For i = 0 To (mWord.Length - 1) ' If mWord(AscW(mWord.Chars(i))) = mWord.IndexOf(chrGuessLetter) Then ' ' mUncoveredLetters = ' Else ' 'where to hang them ' End If 'Next ' mModifiedWord = ModifiedWordArray 'End If End Sub
TryALetter is a sub that accepts a character. It finds all occurrences of the guessed letter
in mWord and changes the “*”’s at the same location in mUncoveredLetter to the actual letter. (A useful method to use is .IndexOf, for example, mWord.IndexOf(chrGuessLetter) returns the location of the character in the string. If a negative number is returned, the letter is not in the string.) If the letter is in the word, then you need to “uncover” it in mUncoveredWord. One way to do this is to create an array of characters and assign mUncoveredLetters to that array.
That way you can loop through comparing each character in mWord (mWord.Chars(i)) to the guess letter and if it matches assign the letter to the same location in your UncoveredLetters array. Once you have processed the entire word, set mUncoveredLetters equal to the array in order to transfer the new set of letters back to the mUncoveredLetters variable. If the letter is not in your word at all, your program should increment HangmanImage by 1.
Comment