Solved

ASP.NET/VB: Randomly Select an Option

Posted on 2013-06-23
1
323 Views
Last Modified: 2013-06-24
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
Comment
Question by:hankknight
1 Comment
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39269803
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question