Repetition structures in visual basic

Assignment Help Visual Basic Programming
Reference no: EM13820287

PART  1

This lab requires you to write the program in the Visual Basic console application using loops. Read the following program prior to completing the lab.

Food Incorporated wants you to create a small program that will ask customers to enter their name, address, city, state, zip code and to validate that they provide the information in order to complete the program.

Complete the following lab tasks.

Step 1: Start the program

a. Create a new Visual Basic Console Application by going to file ? New project

b. Name the application lab4.2_fname_lname and click Ok

Step 2: Create the initial code asking for the user's name

a. In the main function write the following code to request a user to enter their name and pause the program when finished:

'Create the variables

Dim strFname As String = ""

Console.Write("Enter your first name:")

strFname = Console.ReadLine()

Console.Write("Hello " & strFname & vbCrLf)

Console.Write("Press any key to close")

Console.ReadLine()

PT1420: Repetition Structures in Visual Basic

PART  2

Your module looks like this:

b. Run the program by clicking the green arrow that points to the right or by going to debug ? start debugging Test your program by first entering your name; observe what happens. Test your program again but this time just press Enter. Note, nothing stopped you from entering your name. Your output looks like this:

PT1420: Repetition Structures in Visual Basic

PART  3

Step 3: Add a module to collect input

a. Create a new module called collectAndValidateName() and move the input of the users information to this module. Update your main function to look like the following:

Sub collectAndValidateName()

'Create the variables

Dim strFname As String = ""

'Create the first validation loop

'Prompt for user to enter name

Console.Write("Enter your first name:")

'Read user input

strFname = Console.ReadLine()

'check if the user entered a value

Console.Write("Hello " & strFname & vbCrLf)

Console.Write("Press any key to close")

Console.ReadLine()

b. Call your collectAndValidateName() module from the main() module. Update your main function to look like the following:

Sub Main()

PT1420: Repetition Structures in Visual Basic

PART  4

Call collectAndValidateName()

Console.Write("Press any key to close")

Console.ReadLine()

End Sub

Your module looks like this:

Step 4: Add Input Validation using a do while loop

a. We will now add the code to make sure that the user submits their name before we continue and say hi to them. Update your collect AndValidateName module to look like the following:

'Create the first validation loop

Do While strFname = ""

'Prompt for user to enter name

Console.Write("Enter your first name: ")

'Read user input

PT1420: Repetition Structures in Visual Basic

PART  5

strFname = Console.ReadLine()

'check if the user entered a value

If strFname = "" Then

Console.Write("You did not enter a value, try again" & vbCrLf)

End If

Loop

Console.Write("Hello " & strFname & vbCrLf)

End Sub

b. Run the program by clicking the green arrow that points to the right or by going to debug ? start debugging

o Test your program by first entering your name, observe what happens

c. Test your program again but this time just hit enter. Note that your program now requires you to enter your name before continuing to say hello to them. Your output looks like this:

PT1420: Repetition Structures in Visual Basic

PART  6

Step 5: Add additional code to ask the user to enter their address, city, state and zip code. You can use any of the looping methods covered in this week's material.

a. Using step 3 create additional modules to validate that the user provides his or her address, city, state, and zip code. Your module looks like this:

PT1420: Repetition Structures in Visual Basic

PART  7

b. Using step 4, create loops to validate that the user provides his or her address, city, state, and zip code.

c. Write out to the screen the information that the user provided.

d. Run the program by clicking the green arrow that points to the right or by going to debug ? start debugging

e. Test you code to make sure you have to provide each piece of information before exiting the program. Your final output looks like this:

PT1420: Repetition Structures in Visual Basic

PART  8

PT1420: Repetition Structures in Visual Basic

PART  9

Step 6: Submit the Visual Basic code as a compressed (zipped) folder using the following steps:

a. Open Windows Explorer --> Start --> All Programs --> Accessories --> Windows Explorer. Your Windows Explorer might look as follows:

b. In Windows Explorer, navigate to the folder that contains your project files. Your Windows Explorer might look as follows:

PT1420: Repetition Structures in Visual Basic

PART  10

(If you don't recall you can check in Visual Studio by opening your project, right click module1.vb file and view the properties. Look at the full path ex. C:\Users\instructor\Documents\Visual Studio 2010\Projects\myFirstProgram\myFirstProgram\Module1.vb; in this case navigate to C:\Users\instructor\Documents\Visual Studio 2010\Projects). Your module properties might look as follows:

c. Right click on your project folder and choose send to --> compressed folder. This creates a zip file of all your code. Your Windows Explorer might look as follows:

PT1420: Repetition Structures in Visual Basic

PART  11

d. Attach the compressed folder you created to your submission. Your Windows Explorer might look as follows:

THOUGHT QUESTIONS:

1. Were you able to successfully complete the code to validate the address, city, state, and zip code? If not, what went wrong?

2. What types of loops did you try to use in this assignment?

3. What are some ways that you think this program could be improved?

Reference no: EM13820287

Questions Cloud

Identify the nutritional needs for a developing embryo : Identify the nutritional needs for a developing embryo and fetus and how to obtain them - Identify health concerns or disease associated with poor nutrition during the gestation period.
The products formed when nitroglycerin undergoes hydrolysis : the products formed when nitroglycerin undergoes hydrolysis
Determine the scope of the district production warehouse : Review the project case. Determine the scope of the District 4 Production Warehouse Move project from the information provided in the case
Rovide examples of good and bad nutritional choices : Identify the nutritional needs for a developing embryo and fetus and how to obtain them - Identify health concerns or disease associated with poor nutrition during the gestation period.
Repetition structures in visual basic : Repetition Structures in Visual Basic
Realistic strategies that carnival corporation : Develop two feasible/realistic strategies that Carnival Corporation could follow. you should provide one short term and one long term strategy and give a brief description about the details of "WHAT" each strategy is about. Your strategies should ..
Define community in any way you see fit : How is community both antithetical to and supportive of individuality in the works we've read this semester? You can define community in any way you see fit, be it family or "society" or humanity. Decide your focus.  How would you present this novel ..
What characteristics the effective leader possessed : Describe what characteristics the effective leader possessed, and explain how those characteristics contributed to his or her success.
Assignment on create an encoding scheme : Create an encoding scheme

Reviews

Write a Review

Visual Basic Programming Questions & Answers

  About vbs script

Write at least one non-trivial paragraph that explains in detail either a significant problem you had and how you solved it, or, if you had no significant problems, something you learned by doing the exercise.

  Explanation of benefits to the business

Explanation of benefits to the business of using your proposed system, both tangible and intangible

  Arrays write a program using dynamic arrays to record the

write a program using dynamic arrays to record the high temperatures of last ltbrgtseven days and to display all of

  Calculate and display the cost for operating home appliance

Validate that the data entered has the correct format and is within a reasonable range. Calculate and display the cost for operating a home appliance as soon as the data is entered.

  Using visual studio, create sample class implementations

Using Visual Studio, create sample class implementations. These will be code stubs that provide the basis for the classes you will be using

  Program in basic which prompts user to input two integers

Write down the program by using Small Basic which prompts the user to input two integers: firstNum and secondNum (firstNum must be less than secondNum).

  Apply graphical user interface design principles

Apply graphical user interface design principles - Design conditional and iteration constructs appropriate to a given programming task and design well-written and readable programs using a disciplined coding style, including documentation and indenta..

  Develop a simple application for the ice-cream games

Develop a simple application for the Ice-Cream Games, which captures information about athletes and populates a list box.

  Basics of visual design

Focus on Web Design II: This assignment is part of the module MODULE 4: BASICS OF VISUAL DESIGN and hasn't been unlocked yet. Completion Prerequisites. The following requirements need to be completed before this page will be unlocked: MODULE 4: BASIC..

  Help an elementary school student learn multiplication

Write a program that will help an elementary school student learn multiplication. Use a Random object to produce two positive one-digit integers. The program should prompt the user with a question, such as "How much is 6 times 7?"

  Write visual logic program for customer-s bank account

Write a visual logic program to aid balance a customer's bank account. the program must read numeric values that represent banking transactions.

  Write a program that asks the user to respond to a question

Write a program that asks the user to respond to a question by entering either 1 for yes or 2 for no.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd