D
darrel
I can grab a random number in vb.net like this:
Dim RandomClass As New Random
Dim RandomNumber As Integer
RandomNumber = RandomClass.Next(1, 26)
However, what I want is a random number. Short of making a case statement
with 26 options, is there a more streamlined way to get an integer between
1-26 translated into one of the letters?
Also, in case there's a more efficient way to handle this, this is what I'm
trying to accomplish:
I have a dataset that will have about 1000 records. This is a list of
companies ordered alphabetically. We need the list that is displayed to
start with a random letter of the alphabet, so that "AAA Company Name"
doesn't always get listed first (and get an unfair advantage).
I'm grabbing the dataset, sorted alphabetically, then creating a random
letter. I then loop through the dataset looking for the first company that
has a first letter matching the random letter. I then start writing out the
records from that point, and loop back to the beginning when I reach the
end. Is there a better way to handle that? Maybe re-sort the DS without
having to loop through it all?
-Darrel
Dim RandomClass As New Random
Dim RandomNumber As Integer
RandomNumber = RandomClass.Next(1, 26)
However, what I want is a random number. Short of making a case statement
with 26 options, is there a more streamlined way to get an integer between
1-26 translated into one of the letters?
Also, in case there's a more efficient way to handle this, this is what I'm
trying to accomplish:
I have a dataset that will have about 1000 records. This is a list of
companies ordered alphabetically. We need the list that is displayed to
start with a random letter of the alphabet, so that "AAA Company Name"
doesn't always get listed first (and get an unfair advantage).
I'm grabbing the dataset, sorted alphabetically, then creating a random
letter. I then loop through the dataset looking for the first company that
has a first letter matching the random letter. I then start writing out the
records from that point, and loop back to the beginning when I reach the
end. Is there a better way to handle that? Maybe re-sort the DS without
having to loop through it all?
-Darrel