Messages and User Inputs
Exercise 5.02

Exercise 5.02

The aim of this exercise is to allow the user to add items to a list using input boxes.

Files Needed

Click here to download the file you need for this exercise.

Instructions

  1. Open the Lottery List.xlsx file, create a new module and add a new subroutine.
  2. Congratulations: you've won the lottery!  Your task is to write a procedure which uses input boxes to build a shopping list.
Beginning of list

Feel free to delete the suggested items that are already in the list.

 
  1. Write code to display an Excel input box which asks the user to enter the name of the item they wish to purchase.  Capture the result in a String variable.
Item input

Be as extravagant as you like.

 
  1. Add code to check that the user entered a value before clicking OK.  If not, display a message and exit from the procedure.
Error empty input

We don't want to add an un-named item to the list.

 
  1. Add code which displays a message and exits from the procedure if the user clicks Cancel on the input box.
Cancel error

Your message can be gently encouraging or downright pushy.

 
  1. Add a second Excel input box which asks the user the estimated cost of the item and return its result to a Double variable.  Make sure that the user can only enter a number.
Error not a number

If you don't enter a number you should see this warning.

 
  1. Write code to add the new item to the end of the list.
Add to list

The new item should appear at the end of the list.

 

Answer Files

Click here to download a file containing a suggested answer.

This page has 0 threads Add post