Challenges

1. Add a modeless form (set the ShowModal property of the UserForm object) to a VBA project then add two Command Button controls to a worksheet. Using their Click() event procedures, use one Command Button control to show the form, and the other Command Button control to hide the form.

2. Add a RefEdit control and a Command Button control to the form created in the previous challenge. The RefEdit control is for the user to display a selected range. Then add code to the Command Button control such that it changes the format of the selected range by increasing its font size to 24 and its color to green (vbGreen or RGB(0,255,0)). You must show the form as modal or your program may lock up.

3. Create a form that contains a List Box control. Use the AddItem() method of the List Box control to display the contents of column A of the active worksheet. Hint: Use a For/Each to iterate through the cells in column A in the Activate() event procedure of the UserForm object.

4. Add a Command Button control to the form from the previous challenge and change the MultiSelect property of the List Box control to allow multiple selections. Add code to the Click() event procedure of the Command Button control that will copy the selected values of the List Box control to column B of the worksheet. Hint: Use the Selected property of the List Box control to return an array of Boolean values that can be used to determine which items are displayed in the control and have been selected by the user. Use the ListCount and List properties of the List Box control along with a For/Next loop to return the selected values of the List Box control if its Selected property is true.

5. Alter the Blackjack game to pay double the bet if the player is dealt a blackjack (one Ace and one card of value 10).

6. Alter the Blackjack game to immediately end if the player or dealer is dealt blackjack. Whoever has the blackjack is declared the winner and the other player is not allowed to draw. If both players are dealt blackjack, then it's a push.

7. Doubling down is the process of doubling your bet after the first two cards are dealt. If you choose to double down, then you can only draw one more card. Add this feature to the Blackjack game.

8. Splitting is the process of splitting your first two cards into two separate hands. You then draw one more card for each hand and you are not allowed any more draws. Your bet applies to both hands and each hand competes against the dealer's hand. Add this feature to the Blackjack game.

(continues)

Challenges (continued)

9. Alter the Blackjack game to incorporate a MultiPage control with two pages on the Blackjack form. The first page of the MultiPage control should contain the existing Blackjack game table. The second page of the MultiPage control should contain a List Box control with two columns (set the ColumnCount property). Use the List Box control as a card counter. The first column should list the card type (Ace, King, Queen, and so on). The second column should list the number of cards that have been played from the deck for the card type listed in the adjacent row of the first column. Don't forget to reset the List Box when the deck is shuffled.

(chapter)

Biorhythm Awareness

Biorhythm Awareness

Who else wants to take advantage of biorhythm awareness to avoid premature death, escape life threatening diseases, eliminate most of your life altering mistakes and banish catastrophic events from your life.

Get My Free Ebook


Post a comment