Answer to Question #20139 in Visual Basic for Jr

Question #20139
how can you randomize an array?
Console.WriteLine("program is running")
Dim name(9) As String
Dim counter As Integer

Randomize()
For counter = 0 To 9
Console.WriteLine("enter your name" * counter)

name(counter) = Console.ReadLine
Next


Console.WriteLine("your names have been randomized")

Console.ReadLine()


here is my code i need to randomize the ten names and display them, i tried everything but i can't randomize them, please help!!
1
Expert's answer
2012-12-06T09:50:17-0500
Module Module1

Sub Main()

Dim name(9) As String
For i = 0 To 8
Console.WriteLine("enter your name " + (i + 1).ToString() + ":
")
name(i) = Console.ReadLine
Next
Console.WriteLine("your names have been randomized")
Dim random As New Random()

For i = 0 To 8
Dim number = random.Next(0, 8)
Console.WriteLine(name(number))
Next


Console.ReadLine()
End Sub

End Module

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS