codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  new to VB and learning  herbie at 15:10 on Tuesday, November 06, 2007
 

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








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: partial string sorting of arrays
•  Passing Multiple Values from a child window to parent window
•  Re: inserting values from pop up
•  jumping to a different web page
•  Re: Page Load is getting called twice
•  values from asp to html
•  Re: Write text strings to Serial Port
•  Calcluate Date Difference [Seriouslt a new challenge]
•  source code to generate perl library


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007