Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Need help with array and random class (http://www.go4expert.com/forums/help-array-random-class-t25085/)

petrina1 27Feb2011 05:59

Need help with array and random class
 
I have these state and capital arrays below; I am trying to create a program that has one label and four radio buttons... When you run the program a question comes up in the label... what is the capital of (state name) ....then four state capitals show up in the radio buttons and you have to make a choice. Need help with random class..... a string to hold the correct anwser.. PLEASE HELP; Thank you in advance

Code:

'Declare module level variables
Private aStates() As String = {"Alabama", "Alaska", "Arizona", "Arkansas", "California", _
"Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", _
"Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", _
"Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", _
"New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", _
"Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", _
"Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"}
 
Private aCapitals() As String = {"Montgomery", "Juneau", "Phoenix", "Little Rock", "Sacramento", _
"Denver", "Hartford", "Dover", "Tallahassee", "Atlanta", "Honolulu", "Boise", "Springfield", _
"Indianapolis", "Des Moines", "Topeka", "Frankfort", "Baton Rouge", "Augusta", "Annapolis", "Boston", _
"Lansing", "St. Paul", "Jackson", "Jefferson City", "Helena", "Lincoln", "Carson City", "Concord", _
"Trenton", "Santa Fe", "Albany", "Raleigh", "Bismarck", "Columbus", "Oklahoma City", "Salem", _
"Harrisburg", "Providence", "Columbia", "Pierre", "Nashville", "Austin", "Salt Lake City", "Montpelier", _
"Richmond", "Olympia", "Charleston", "Madison", "Cheyenne"}


pein87 9Mar2011 03:36

Re: Need help with array and random class
 
you need to add the count of the array elements. or ReDim it. This is visual; basic though and not php.

Code: Visual Basic

Private MyStates(0 to 49) As String
MyStates(0) = "Kansas"


Or

Code: Visual Basic

Private MyStates() As String

ReDim MyStates(0 to 49) As String

MyStates(0) = "Kansas"


As for the class just use a function to select 3 randoms and have it except the actual capital as a param so it can loop through and find it in the array.


All times are GMT +5.5. The time now is 09:29.