What's the cricket score?

Cricket is a popular sport in British Commonwealth countries, like Australia, and India. Each match has two sides (teams), as usual. There are four components to a side's score:

  • Boundaries (sixes): 6 points each
  • Boundaries (fours): 4 points each
  • Singles: 1 point each
  • Sundries: 1 point each

You can read more about cricket scoring, if you want to know more.

Write a VBA program to compute a score given the information above. When the worksheet opens:

MT

The user enters four values, clicks Run, and the program computes the score. For example:

Sample output

All input values must be numeric and zero or more. If there are errors, show messages next to each erroneous cell. For example:

Errors

Be sure to clear old error messages and output when the program runs.

Do not start from scratch. Download this worksheet, and add the code you need. Warning! Don't click the link and open in Excel immediately. Click the link, save the file, and then open it as a separate step.

  • Do not change any code in the sub cmdRun_Click. Do not add, change, or remove anything.
  • Do not change the declarations of any sub.
  • Put code in every sub given in the starting worksheet, and call every sub at least once.
  • Put any code you want in the subs, apart from cmdRun_Click, which must remain unchanged.
  • Add any new subs you want.

The usual coding standards apply.

Upload your solution.

(If you were logged in as a student, you could submit an exercise solution, and get some feedback.)

Referenced in: