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

1-demensional array string cannot be converted to integer

P: 11
i am doing an assignment in vb.net. i have to select at random from and array what i have is

dim country(29) as string
dim random as new random

txtcountry.text = random.next(country)

I keep getting that this error
1-demensional array string cannot be converted to integer

can anyone help?

thanks
Mar 16 '07 #1
Share this Question
Share on Google+
4 Replies


markmcgookin
Expert 100+
P: 648
i am doing an assignment in vb.net. i have to select at random from and array what i have is

dim country(29) as string
dim random as new random

txtcountry.text = random.next(country)

I keep getting that this error
1-demensional array string cannot be converted to integer

can anyone help?

thanks
Dim randomNo as Int

...

randomNo = toInt(random)

txtcountry.text = randomNo(country)

?? would that work?
Mar 16 '07 #2

P: 11
No it didn't work but thanks anyway
Mar 16 '07 #3

100+
P: 1,646
When you create a random number between 0 and 28 you can then use it as an array index to select a random string. The index is the part in brackets so you need to put the random number in the brackets.
country(random number here)
Mar 16 '07 #4

P: 11
I did it and this is how, if u want to know.

Private choice As Integer
Private random As New Random

choice = random.Next(0, 29)
txtcountry.Text = country(choice)
Mar 28 '07 #5

Post your reply

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