Option Strict On Option Explicit On Module Guesswork Const charLimit As Integer = 12 Dim sWord(charLimit) As Char Dim uGuess(charLimit) As Char Dim wordInput As String Const _space As String = " " Const blank As String = "__" Dim letrInput As String Dim correctLetr(sWord.Length) As Char Dim wrongLetr(totAttempts) As Char Dim totAttempts As Integer = 0 Dim attemptsEof As Integer = 0 Dim spcCounter As Integer = 0 Sub gameModule() Console.WriteLine("Enter the secret word: ") wordInput = Console.ReadLine sWord = wordInput.ToCharArray Do Until correctLetr = sWord Do While sWord.Length > 12 Console.WriteLine("Enter word with 12 or less characters: ") wordInput = Console.ReadLine sWord = wordInput.ToCharArray Loop sWord = wordInput.ToCharArray Console.WriteLine() Console.WriteLine() Console.WriteLine() If correctLetr.Length < sWord.Length Then Console.WriteLine("Enter a letter: ") letrInput = Console.ReadLine Do While letrInput.Length > 1 Console.WriteLine("Enter one letter at a time: ") letrInput = Console.ReadLine Loop uGuess = letrInput.ToCharArray End If For count4 = 0 To sWord.Length - 1 For count6 = 0 To uGuess.Length - 1 If uGuess(count6) = sWord(count4) Then correctLetr = letrInput.ToCharArray End If 'Can you give me some insight as to why this isn't working? It is ' putting the letrInput into both correctletr array ' and wrongletr array. I've tried it several ways, looked on ' msdn forums, and it seems like it should work, but its not If uGuess(count6) <> sWord(count4) Then wrongLetr = letrInput.ToCharArray End If Next Next Console.Clear() 'I have these two writing in the program so I could see what values are being assigned ' to them and it confirms they are being assigned the same character regardless 'of the loop I set up Console.WriteLine(correctLetr) Console.WriteLine(wrongLetr) Console.WriteLine() Console.WriteLine("Incorrect letters: " & wrongLetr) Console.WriteLine() totAttempts = CInt((sWord.Length / 2) + 1) Console.WriteLine("Total Attempts: " & totAttempts) Console.WriteLine("Missed Attempts: " & wrongLetr.Length) attemptsEof = totAttempts - wrongLetr.Length Console.WriteLine("Remaining attempts: " & attemptsEof) Console.WriteLine() For count1 = 0 To sWord.Length - 1 For count2 = 0 To correctLetr.Length - 1 If correctLetr(count2) = sWord(count1) Then Console.Write(correctLetr(count2) & _space) End If If correctLetr(count2) <> sWord(count1) Then Console.Write(blank & _space) End If Next Next Console.WriteLine() Loop End Sub Sub Main() Dim newGame As String = "yes" Dim quitGame As String = "no" Dim gameInput As String Console.WriteLine("Welcome to GuEsS WoRd!") Console.WriteLine() Do Until correctLetr = sWord gameModule() If correctLetr = sWord Then Console.WriteLine("You Win.") Console.WriteLine("Would you like to play again?") gameInput = Console.ReadLine ElseIf newGame = gameInput Then gameModule() ElseIf quitGame = gameInput Then End If If wrongLetr.Length = totAttempts Then Console.WriteLine("You Lose.") Console.WriteLine("Would you like to play again?") gameInput = Console.ReadLine If newGame = gameInput Then gameModule() ElseIf quitGame = gameInput Then End If End If Loop Console.Read() End Sub End Module
Last edited by a moderator: