littlechikon Posted July 9, 2009 Report Posted July 9, 2009 I need to make a program that generates 5 random numbers and letters, in VB9 but I am having trouble. Can someone help me ? =]
Rogue Modder Posted July 9, 2009 Report Posted July 9, 2009 Module ye Sub Main() Dim intRandomNumber As Integer = GenerateRandomInteger(1000, 9999) Dim strRandomString As String = GenerateRandomString(16) Console.WriteLine("Random Number:" & intRandomNumber.ToString()) Console.WriteLine("Random String:" & strRandomString) Console.ReadLine() End Sub Private Function GenerateRandomInteger(ByVal intMin As Integer, ByVal intMax As Integer) As Integer Dim randomNumber As Random = New Random Return randomNumber.Next(intMin, intMax) End Function Private Function GenerateRandomString(ByVal intLenghtOfString As Integer) As String Dim randomString As StringBuilder = New StringBuilder Dim randomNumber As Random = New Random Dim appendedChar As Char For i As Integer = 0 To intLenghtOfString appendedChar = Convert.ToChar(Convert.ToInt32(26 * randomNumber.NextDouble()) + 65) randomString.Append(appendedChar) Next Return randomString.ToString() End Function End Module
ixGAMEOVERxixx Posted July 10, 2009 Report Posted July 10, 2009 Or.. Dim Random As New Random() TextBox1.Text = Chr(Random.Next(65, 90)) & Chr(Random.Next(65, 90)) & Chr(Random.Next(65, 90)) & Chr(Random.Next(65, 90)) Life is simple
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now