"As a student, I don't really feel qualified to what good and bad code is" writes Dan, "at least, that's how I felt before landing my first internship."
"When I asked my 'mentor' why he didn't just use the Asc
function (which I found after a few-second search) to convert a random number to a random character, he responded that this seemed cleaner."
function getRandomChar(temp) dim c c= "S" select case temp mod 36 case 0 c="A" case 1 c="4" case 2 c="Z" case 3 c="7" case 4 c="C" case 5 c="1" case 6 c="K" case 7 c="6" case 8 c="B" case 9 c="9" case 10 c="Y" case 11 c="2" case 12 c="D" case 13 c="8" case 14 c="F" case 15 c="3" case 16 c="N" case 17 c="5" case 18 c="G" case 19 c="7" case 20 c="J" case 21 c="1" case 22 c="M" case 23 c="P" case 24 c="#" case 25 c="Q" case 26 c="2" case 27 c="R" case 28 c="X" case 29 c="T" case 30 c="U" case 31 c="V" case 32 c="W" case 33 c="4" case 34 c="H" case 35 c="E" end select getRandomChar=c end function
And from Corey Richardson, a triply-random way to get a double.
Public Function RandDouble() As Double Randomize(Rnd) Dim RandList As New List(Of Double) For i = 0 To 9 RandList.Add(Rnd) Next Dim ArrayList = RandList.ToArray.shuffle(10) Return ArrayList(Rnd() * 9) End Function
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!