I have spent about 40 hours on this code so far. I have finally cleared the faults from it. I am a new coder. What I am trying to get it to do is to display the users name is the "type your guess " box as in "type your guess Robert." and the additional task is to provide feedback to the user that says if the number is too high or too low until they eventually guess it, providing feedback that they guessed it. Although no code errors come up when you run the code, the code crashes once you initially input a guess.
'Initialization Section Option Explicit Const cGreetingMsg = "Pick a number between 1 - 100" Dim intUserNumber, intRandomNo, strOkToEnd, intNoGuesses, strOkToEnd1 Randomize intRandomNo = FormatNumber(Int((100 * Rnd) + 1)) intNoGuesses = 0 function GetPlayersName() GetPlayersName = InputBox("What is your first name? ") 'Main Processing Section End Function select case strOkToEnd case 1 If FormatNumber(intUserNumber) < intRandomNo Then 'Test to see if the user's guess was too low MsgBox "Your guess was too low. Try again", ,cGreetingMsg End If case 2 If FormatNumber(intUserNumber) > intRandomNo Then MsgBox "Your guess was too high. Try again", , cGreetingMsg End If 'Loop until either the user guesses correctly or the user clicks on Cancel End Select 'Generate a random number Do Until strOkToEnd = "yes" 'Prompt user to pick a number intUserNumber = InputBox("Type your guess:"), GetPlayersName, cGreetingMsg intNoGuesses = intNoGuesses + 1 'See if the user provided an answer If Len(intUserNumber) <> 0 Then 'Make sure that the player typed a number If IsNumeric(intUserNumber) = True Then Else If IsNumeric(intUserNumber) = False Then MsgBox "Sorry. You did not enter a number. Try Again." strOkToEnd = "yes" 'Test to see if the user's guess was correct If FormatNumber(intUserNumber) = intRandomNo Then MsgBox "Congratulations! You guessed it. The number was " & _ intUserNumber & "." & vbCrLf & vbCrLf & "You guessed it " & _ "in " & intNoGuesses & " guesses.", ,cGreetingMsg strOkToEnd = "yes" End If End If End If End If Exit Do Loop