Solved

ASP.NET/VB: Randomly Select an Option

Posted on 2013-06-23
1
319 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 74

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now