Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9229285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:32:02+00:00 2026-06-18T05:32:02+00:00

Have to pick a random number from an arraylist, to generate proper information from

  • 0

Have to pick a random number from an arraylist, to generate proper information from a database, its bugging on the rnd line at this moment

    Dim rn As New List(Of Integer)
    Dim QPass As String
    rn.Add(71)
    rn.Add(72)
    rn.Add(79)
    rn.Add(80)
    Dim index As Integer = CInt(Math.Floor(Rnd() * 4))
    Dim randomValue As Integer = CInt(rn(index))
    QPass = randomValue.ToString()
    Session("Pt2") = rn
    PT2imgImage.ImageUrl = "showImage.ashx?i=" + QPass
    PT2imgImage.Width = Unit.Pixel(600)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:32:03+00:00Added an answer on June 18, 2026 at 5:32 am

    Here

    rn = rn(Rnd() * 4)
    

    you are trying to put an Integer (the value selected from the ArrayList), into a variable declared as ArrayList. That won’t work. Use a new variable:

    Dim index As Integer = CInt(Math.Floor(Rnd() * 4))
    Dim randomValue As Integer = CInt(rn(index))
    
    QPass = randomValue.ToString()
    Session("Pt2") = randomValue
    

    CInt(Math.Floor(...)) ensures that the floating point value returned from Rnd() * 4 is correctly rounded down and converted into an integer, which can then be used to index an array list. Eventually, you might want to replace this by a more .NET way to get a random number (e.g. Random.Next). Rnd is mainly for backwards compatibility.

    The CInt around rn(index) is required, since you use an old, untyped ArrayList instead of a new, shiny, strongly-typed List(Of Integer). If you use the latter, you can remove the outer CInt.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When you have Math.floor(Math.random()*10)+1 its supposed to pick a random number between 1-10 from
Possible Duplicate: Pick random property from a Javascript object suppose I have a javascript
Just random pick some methods that I have found: sforce.connection.describeSObject sforce.SearchResult sforce.sObject sforce.LeadConvert() sforce.connection.create()
I have a function to pick out lumps from a list of strings and
I have a custom library that can pick mulitple images from the camera roll,
I have used the following code to pick up an image from phone's gallery:
I have a requirement for my MAVEN build to pick a single jar from
I am trying to make a script to pick random number between two numbers
I am writing a web app to pick random lists of cards from larger,
Does Java have any functionality to generate random characters or strings? Or must one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.