JORDAN UNIVERSITY OF SCIENCE AND TECHNOLOGY COMPUTER SCIENCE DEPARTMENT

advertisement
JORDAN UNIVERSITY OF SCIENCE AND TECHNOLOGY
FACULTY OF COMPUTER & INFORMATION TECHNOLOGY
COMPUTER SCIENCE DEPARTMENT
CS 116 (Visual Basic 6)
Section 14 (Ms. Noor Al Zaghal)
Assignment # 2
Due Date 31/10/2007
Objectives
1. Understand how to generate random numbers.
2. To understand the use of selection structures (IF, IF/ELSE and Case Select).
3. To understand how to use logical expressions.
Exercise 1:
Write a VB program that does the following:
1. Generate a random integer number (using Rnd) between 10…100 when you
click at the CmdGenerate and save it in the integer variable n1.
2. Guess the number n1 by Input another integer number within the same range
and save it in integer variable n2 by using Input box when you click at
CmdGuess then,
a) If n2 > n1 Show a message to the user to enter another number less
than n2.
b) If n2 < n1 Show a message to the user to enter another number greater
than n2.
c) If n2 = n1 Show a message to the user to tell him that he/she WIN.
(a)
(b)
Note:
- Using IF , IF/ELSE , IF / ELSEIF statement .
- Using Select Case statement.
(c)
Download