473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

I dont know how I did it , i think there has mistakes

Code the click event of the Play Game button to do the following
i. Generate a random integer between 1 and 100
ii. Code a loop that will end when the user guesses the number or 10 guesses have failed to find the number.
iii. Use an inputbox function so that the user can enter each guess.
iv. If the user does not enter an integer number display an error messagebox, show the answer, and exit the loop. If the user enters a number outside the range of 0 – 100 display an error messagebox, show the answer, and exit the loop.
v. Show each guess in the Guesses Label using concatenation.
vi. If the guess is incorrect change the message portion of the InputBox function to “Guess Higher” or “Guess Lower”. Hint: Only use one InputBox – not three different ones.
vii. Use a messagebox to inform the user that the correct number has been guessed or that ten guesses have failed to guess the number
Expand|Select|Wrap|Line Numbers
  1. Private Sub btnPlay_Click(sender As Object, e As EventArgs) Handles btnPlay.Click
  2.         Dim intRandom As Integer
  3.         Dim intAttempt As Integer
  4.         Dim intcount As Integer
  5.  
  6.         Randomize()
  7.         intRandom = CInt(Rnd() * 100) + 1
  8.         intAttempt = Val(InputBox("Enter a number between 1 and 100:"))
  9.         intcount = 1
  10.         Do Until intcount = 10
  11.             If intAttempt < intRandom Then
  12.                 intAttempt = Val(InputBox(CStr(intAttempt) & " Guess Higher.  " & CStr(10 - intcount) & vbNewLine & "Enter another number between 1 and 100:"))
  13.             ElseIf intAttempt > intRandom Then
  14.                 intAttempt = Val(InputBox(CStr(intAttempt) & "Guess Lower. " & CStr(10 - intcount) & vbNewLine & "Enter another number between 1 and 100:"))
  15.             ElseIf intAttempt = intRandom Then
  16.                 Exit Sub
  17.             End If
  18.         Loop
  19.         MsgBox("Sorry. You failed !")
Oct 26 '13 #1
0 974

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Farooq Khan | last post by:
hi, my development team has been assigned a project that involves writing our own Web service. i happen to be a C++ programmer, new to C#/ASP.net. i dont know where to begin with......any...
2
by: Pavel Novotny | last post by:
H I'm trying to import a | seperated text from string variable which represents a tabl with several fields, eg 6124079|PRIRUBA 11 DN250 PN6;CSN131160.0;11369.1;CSN131005.50|KS|11,100000|3437,...
0
by: arunavlp | last post by:
hi, I am new to .net , i am using VB.Net (Web form). I dont know how to pass parameters to stored function. Regards, Arun.S
2
by: hojjatnikan | last post by:
please help me this code 62EH&5gx0wiqoQFw is this name ( Belux) but i dont know how convert it i dont know the algorithm of this code plead help me
2
by: Tiruak | last post by:
Hi there. Thanks in advance for the people reading and trying to help. I'm very begginer using flash and action script, and I tryed to do this one navigation menu. Since I dont have experience...
2
by: Sreenivas | last post by:
I dont know how to compile cpp programs with gcc as i am new to gcc and cpp. could anybody help me out? Thanks&Regards, Srinivas Reddy Thatiparthy.
2
by: shwetaT | last post by:
i m working in php domain and i dont know much about php,so will u plz suggest me some good sites through which i learn php very well n fast
8
risk32
by: risk32 | last post by:
Hi all. I have a really confusing problem. I'm using Swing and I'm trying to do a confirmation box : int reply; String message = "Do you want to input another number?"; String title = "Input...
2
by: sailormoon | last post by:
this information i put in data.txt 11221 MOHD IRFAN 80 70 11222 NURUL FITRAH 80 90 11223 MOHD FARHAN 70 80 11224 WAFFIN WARDAH 80 60 11225 SYAMSUL 50 50 99999 TAMAT 0 0 #include<fstream.h>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.