Microsoft Developer
Looping over collections exercise
Harder than average exercise

This Microsoft Developer LOOPING OVER COLLECTIONS exercise is provided to allow potential course delegates to assess their suitability for the Wise Owl EXCEL 2007 VISUAL BASIC course only, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

Exercise: Poker game - generate hands of cards

A full answer to this exercise is provided as part of the training course!

1) Download the files needed to start this exercise: exercise-919.zip (and click here if you experience any problems unzipping this file after downloading it).
2) Las Vegas, 03:15 am.  You are in the final 4 of the World Series poker tournament, with a cash prize of $1,000,000, when someone spills coffee on the cards.
3) Write a macro to generate four hands of random cards:
Exercise screen-shot 2028 A typical deal - Chris Ferguson has two pairs, but maybe you can bluff iwth your single pair of 3s
4) There are many ways to solve this (that is part of the challenge), but here are some hints:
  • The Symbols worksheet contains 4 ranges called Heart, Club, Diamond and Spade, which will give you the symbols you need
  • The expression Int(Math.Rnd * 13) + 1 will generate a card number between 1 and 13 (and simiilarly you could generate the suit)
  • For each new card that you generate, you need to check it is not already on the table
5) When you have finished, save thsi as Poker deal.xlsm - and give yourself a huge pat on the back!

Thank you for showing an interest in this Excel 2007 Visual Basic training course! As mentioned above, full answers to this and other exercises are provided on the course. On all Wise Owl scheduled courses delegates can take away these model answers (together with their own efforts!) on a free USB stick.

All content copyright Wise Owl Business Solutions Ltd 2008.  All rights reserved..