Guessing game Visual Basic 2008

I have multiple questions. How do I make my reset button populate a new random number every time it is pressed.
 
I also need to tweak my help message. I would like each sentence on a new line.

When user enters a blank guess I want the current message to appear but a second message appears also. How do make just first message appear and allow the user to input a correct value.

DOCDGAAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
You want us to guess your code as well?
0
CodeCruiserCommented:
For random numbers:
Dim Rand as new Random
NewValue = Rand.Next(1, 100)


For multiline messages

Messagebox.Show "First Line" & VBCRLF & "Second Line"
0
CodeCruiserCommented:
>When user enters a blank guess I want the current message to appear but a second message appears also. How do make just first message appear and allow the user to input a correct value.

Show the relevant code.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

DOCDGAAuthor Commented:
'Blank guesses are not acceptable
        'Remind user of valid range
        If GuessTextBox.Text = "" Then
            MsgBox("Blank entries not valid, input a value between 1-900.")
            GuessTextBox.Text = CStr(0)
        End If
        If (CInt(GuessTextBox.Text) < 1 Or CInt(GuessTextBox.Text) > 900) Then
            MsgBox("< 1 is not a valid guess or > 900 is not valid guess")
            GuessTextBox.Text = ""   'Clear TextBox
        Else
0
CodeCruiserCommented:
'Blank guesses are not acceptable
        'Remind user of valid range
        If GuessTextBox.Text = "" Then
            MsgBox("Blank entries not valid, input a value between 1-900.")
            GuessTextBox.Text = CStr(0)
            Exit Sub
        End If
        If (CInt(GuessTextBox.Text) < 1 Or CInt(GuessTextBox.Text) > 900) Then
            MsgBox("< 1 is not a valid guess or > 900 is not valid guess")
            GuessTextBox.Text = ""   'Clear TextBox
            Exit Sub
        Else
0
DOCDGAAuthor Commented:
I need to use a textbox instead of a listbox.  Can you help?
Option Strict On


Public Class Guess

    Public number As Integer                'Holds value of random number
    Public guessCounter As Integer = 0      'Tracks guesses
    Public guessPercent As Double           'Guess bar tracker

    ' Creates a single help menu item
    ' A message box displays valuable & meaningful information for program & usage
    Private Sub HelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpToolStripMenuItem.Click
        Dim mystring1 As String = "The program generates a random number and requires the user to input a guess between 1-900."
        Dim mystring2 As String = "The user has a 5 guess limit and the game monitors the users progress."
        Dim mystring3 As String = "The user can view the random number by pressing the show button."
        Dim mystring4 As String = "The user can exit the game by pressing the exit button."

        MsgBox(mystring1 + Environment.NewLine + mystring2 + Environment.NewLine + mystring3 + Environment.NewLine + mystring4)
    End Sub

    Private Sub Robin_Williams_P3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim rndnumber As Random

        rndnumber = New Random   ' Creates an instance of random
        number = rndnumber.Next(1, 900)  ' Sets range for variable (1-900)

        Form1.Show()
    End Sub

    Private Sub ShowButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowButton.Click
        txtGuessNumber.Text = CStr(number) 'Compare input number with random number
    End Sub

    Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
        Me.Close() ' Close program
    End Sub

    Private Sub ResetButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetButton.Click

        ' Generates a new random number
        Dim rndnumber As Random

        rndnumber = New Random   ' Creates an instance of random
        number = rndnumber.Next(1, 900)  ' Sets range for variable (1-900)

        ' Enables guess textbox
        GuessTextBox.Enabled = True

        ' Clears text content
        GuessTextBox.Text = ""

        ' Form color reset
        Me.BackColor = Color.White

        ' Show number label cleared
        ShowMeLabel.Text = ""

        ' Show number button is enabled
        ShowButton.Enabled = True

        ' Resets counter to 0
        guessCounter = 0

        'Reset percentage of guess bar usage
        lblPercent.Text = ""

        'Clears guess history list
        guessNumberListBox.Items.Clear()

        'Reset guess bar to 0
        GuessBar.Value = 0

        'Clear current random number label
        txtGuessNumber.Text = ""

        'Clear high or low status label
        lblStatus.Text = ""

        'Clear current guess
        lblGuessCount.Text = ""
    End Sub

    Private Sub GuessButton_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GuessButton.Click


        'ProgressBar settings based on guess counter
        'Max out at 5 because of 5 guess limit
        GuessBar.Maximum = 5
        GuessBar.Minimum = 0

        GuessBar.Step = 1

        'Blank guesses are not acceptable
        'Remind user of valid range
        If GuessTextBox.Text = "" Then
            MsgBox("Blank entries not valid, input a value between 1-900.")
            GuessTextBox.Text = CStr(0)
        End If
        If (CInt(GuessTextBox.Text) < 1 Or CInt(GuessTextBox.Text) > 900) Then
            MsgBox("< 1 is not a valid guess or > 900 is not valid guess")
            GuessTextBox.Text = ""   'Clear TextBox
        Else
            'Track number of guesses
            guessNumberListBox.Items.Add(GuessTextBox.Text)
            TextBox1.Text = GuessTextBox.Text
            ' Display message if user guesses correctly
            If GuessTextBox.Text = CStr(number).ToString Then
                GuessTextBox.Enabled = False     ' Disables textbox
                Me.BackColor = Color.Red    ' Background color changes red
                MsgBox("You've guessed correctly!!!")
            Else
                ' Guessed too low
                If (CInt(GuessTextBox.Text) < number) Then
                    lblStatus.Text = "Current guess is too low. Please guess again."
                    GuessTextBox.Text = ""
                Else
                    If (CInt(GuessTextBox.Text) > number) Then     ' Guess too high
                        lblStatus.Text = "Current guess is too high. Please guess again."
                        GuessTextBox.Text = ""
                    End If
                End If
            End If

            'Counter increments by 1
            guessCounter = guessCounter + 1

            'Evaluate counter
            '5 guess limit
            If (guessCounter = 5) Then
                GuessTextBox.Enabled = False
            End If

            'Synchronize progress bar with guess counter
            GuessBar.Value = guessCounter
            guessPercent = (guessCounter / 5) * 100
            lblPercent.Text = CStr(guessPercent)

            'Assigns counter value to guess count label
            lblGuessCount.Text = CStr(guessCounter)

        End If
    End Sub

End Class

Open in new window

0
CodeCruiserCommented:
What is that about? Have you got the first two questions right?
0
DOCDGAAuthor Commented:
Yeah, got the first two. Just need this part.
0
CodeCruiserCommented:
You have got all three now with my comment 35362375 addressing the third question so you should ask a new question if you need more help.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DOCDGAAuthor Commented:
Thanks for the help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.