By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,594 Members | 2,059 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,594 IT Pros & Developers. It's quick & easy.

Deciding offense and defense in a basketball game

P: 24
Hello all,

I'm creating a basketball game with two teams of five players. I need to code the program to randomly pick one player from each team to match up. I've set my teams up but I can't figure out how to randomly pick the players. Can someone point me in the right direction? Thanks for your help. Here's my code for the teams:

Expand|Select|Wrap|Line Numbers
  1. Dim homeplayers(4) As String
  2.         homeplayers(0) = "Michelle Johnson"
  3.         homeplayers(1) = "Jennifer Smith"
  4.         homeplayers(2) = "Jessica Doe"
  5.         homeplayers(3) = "Rebecca Clark"
  6.         homeplayers(4) = "Allison James"
  7. Dim awayplayers(4) As String
  8.         awayplayers(0) = "Monica Hargrove"
  9.         awayplayers(1) = "Micah Manning"
  10.         awayplayers(2) = "Amberly Thompson"
  11.         awayplayers(3) = "Linda Reynolds"
  12.         awayplayers(4) = "Brenda Cheatem
Dec 12 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 5K+
P: 8,434
If you look in our "HowTos" section, there are samples that show in VB how to generate a "random" number. Do that, and use the number as the index in your array to choose a name.
Dec 13 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.