• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

ASP.NET/VB: Randomly Select an Option

Using ASP.NET / VB How can I randomly select one of these items to go inside my <li> tag?

Something like this:
PrintOUT &= "<li>" & select_random("Pear","Cherry","Orange","Bannanna","Grape") & "</li>"

Open in new window

0
hankknight
Asked:
hankknight
1 Solution
 
käµfm³d 👽Commented:
Public Function select_random(ByVal ParamArray items() As String) As String
    Dim r As New Random()
    Dim i As New Integer = r.Next(0, items.Length)
    Dim result As String = items(i)

    Return result
End Function

Open in new window

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now