Re: Getting a random letter.
Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance
Find the char value of "a", and then add your random number....
From
http://www.codingforums.com/archive/index.php?t-40281.html
--tsql -- y = Convert.ToChar((Convert.ToInt32(x) + 128));
is how you would do it,
below is a function that will do whole strings rather that just single
characters.
private string DoLameEncryption(string input)
{
string returnValue = string.Empty;
char[] charArray = input.ToCharArray();
foreach(char c in charArray)
returnValue += Convert.ToChar((Convert.ToInt32(c) + 128));
return returnValue;
}
"darrel" <notreal@xxxxxxxxxxx> wrote in message
news:OcQ41ysmGHA.5052@xxxxxxxxxxxxxxxxxxxxxxx
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
.
Relevant Pages
- Getting a random letter.
... I can grab a random number in vb.net like this: ... Dim RandomClass As New Random ... start with a random letter of the alphabet, ... and loop back to the beginning when I reach the ... (microsoft.public.dotnet.framework.aspnet) - extension_pack
... It is used to set upper loop -- limits for non-deterministic values thus avoiding the use of access -- types and enabling the functions to be used for synthesizeable code. ... DivisorVal: integer) return std_logic_vector; function "/"(DividendVal: string; DivisorVal: integer) return std_logic_vector; ... for loopVar in 0 to slvVal'length/4-1 loop ... end loop; if then return not resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to else return resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to end if; ... (comp.lang.vhdl) - extension_pack
... It is used to set upper loop -- limits for non-deterministic values thus avoiding the use of access -- types and enabling the functions to be used for synthesizeable code. ... DivisorVal: integer) return std_logic_vector; function "/"(DividendVal: string; DivisorVal: integer) return std_logic_vector; ... for loopVar in 0 to slvVal'length/4-1 loop ... end loop; if then return not resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to else return resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to end if; ... (comp.lang.vhdl) - extension_pack
... It is used to set upper loop -- limits for non-deterministic values thus avoiding the use of access -- types and enabling the functions to be used for synthesizeable code. ... DivisorVal: integer) return std_logic_vector; function "/"(DividendVal: string; DivisorVal: integer) return std_logic_vector; ... for loopVar in 0 to slvVal'length/4-1 loop ... end loop; if then return not resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to else return resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to end if; ... (comp.lang.vhdl) - extension_pack
... It is used to set upper loop -- limits for non-deterministic values thus avoiding the use of access -- types and enabling the functions to be used for synthesizeable code. ... DivisorVal: integer) return std_logic_vector; function "/"(DividendVal: string; DivisorVal: integer) return std_logic_vector; ... for loopVar in 0 to slvVal'length/4-1 loop ... end loop; if then return not resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to else return resultVar; -- "width mismatch" errors here are due to improper sizing of the vector that this function is assigned to end if; ... (comp.lang.vhdl) |
|