Embed presentation
Download to read offline
![Visual Basic Programming [Lesson 1 To Lesson 4]
1 of 1
Loops: Exercises
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
Date: 2020 May 31
1)
a) Start a new Visual Basic Windows Forms Application project.
b) Add a button to the form and program it according to the steps given below.
c) Generate integers from 1 to 10 using a While…End While statement.
d) Display the generated integers in message boxes.
2)
a) Start a new Visual Basic Windows Forms Application project.
b) Add a button to the form and program it according to the steps given below.
c) Generate integers from 1 to 10 using a Do…Loop statement with While keyword.
d) Display the generated integers in message boxes.
3)
a) Start a new Visual Basic Windows Forms Application project.
b) Add a button to the form and program it according to the steps given below.
c) Generate integers from 1 to 10 using a Do…Loop statement with Until keyword.
d) Display the generated integers in message boxes.
4)
a) Start a new Visual Basic Windows Forms Application project.
b) Add a text box to the form and name it as txtNum.
c) Add a button to the form and name it as btnPrime.
d) Change the Text property of the button to “Is Prime?”.
e) Program the button according to the steps given below.
f) The user is expected to enter an integer in the text box.
g) A prime number (or a prime) is an integer greater than 1 that has no positive divisors
other than 1 and itself.
h) The text “Yes” should be displayed in a message box if the integer entered in the text box
is a prime. Otherwise the text “No” should be displayed in a message box.](https://image.slidesharecdn.com/loopsexercises-200531122901/75/Loops-in-Visual-Basic-Exercises-1-2048.jpg)

This document provides instructions for four Visual Basic programming exercises involving loops. The first three exercises involve generating integers from 1 to 10 using different loop structures and displaying the results in message boxes. The fourth exercise involves programming a button to check if a number entered in a text box is a prime number and displaying "Yes" or "No" accordingly in a message box.
![Visual Basic Programming [Lesson 1 To Lesson 4]
1 of 1
Loops: Exercises
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
Date: 2020 May 31
1)
a) Start a new Visual Basic Windows Forms Application project.
b) Add a button to the form and program it according to the steps given below.
c) Generate integers from 1 to 10 using a While…End While statement.
d) Display the generated integers in message boxes.
2)
a) Start a new Visual Basic Windows Forms Application project.
b) Add a button to the form and program it according to the steps given below.
c) Generate integers from 1 to 10 using a Do…Loop statement with While keyword.
d) Display the generated integers in message boxes.
3)
a) Start a new Visual Basic Windows Forms Application project.
b) Add a button to the form and program it according to the steps given below.
c) Generate integers from 1 to 10 using a Do…Loop statement with Until keyword.
d) Display the generated integers in message boxes.
4)
a) Start a new Visual Basic Windows Forms Application project.
b) Add a text box to the form and name it as txtNum.
c) Add a button to the form and name it as btnPrime.
d) Change the Text property of the button to “Is Prime?”.
e) Program the button according to the steps given below.
f) The user is expected to enter an integer in the text box.
g) A prime number (or a prime) is an integer greater than 1 that has no positive divisors
other than 1 and itself.
h) The text “Yes” should be displayed in a message box if the integer entered in the text box
is a prime. Otherwise the text “No” should be displayed in a message box.](https://image.slidesharecdn.com/loopsexercises-200531122901/75/Loops-in-Visual-Basic-Exercises-1-2048.jpg)