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
• ** Site Hacked ** javascript inserted...
• Losing background/text color when converting HTML to PDF
• hidden div block when displayed, displays at an offset of 200px only in IE 6..
• help - sketch
• Re: Perl Script - File Handling.
• Open a file from website
• Re: to open 5 terminals from one and also execute different commands on each terminal
• read a selected multiple line, those should match some of the values read in the files..
• Help me please


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-2008