|
I am teaching myself VB and have a problem with one of the questions at the end of the chapter I am on
I need to creat a random number then have the user enter a guess from 1-10. Then compare that guess to the random number and move a picbox higer if they need to guess higer or lower if they need to guess lower. I also need to beable to display guess higer..guess lower...you guessed correct.
Here is what I have so far any help would be appericated.
Option Explicit On
Option Strict On
Public Class MainForm
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub brnGame_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles brnGame.Click
' Guess a number then moves the picbox up or down by
' comparing the random number to the user guess
Dim randomGenerator As New Random
Dim guessResult As Integer
Dim inputGuess As Integer
Dim lblAnswer As String
Dim isConverted As Boolean
Dim number As Integer
Dim newLocation As Integer
number = randomGenerator.Next(1, 11)
InputBox("Guess a nunber between 1 and 10", "Guess", "", 450, 400)
If inputGuess > number Then
hellPicBox.Top += 15
ElseIf inputGuess < number Then
hellPicBox.Top -= 15
Else
lblAnswer = "Game Over!"
End If
End Sub
End Class
|
|
|
|
|
|
|
// |