Author Topic: Generate Random Number of any digits using Visual Basic  (Read 4083 times)

bbasujon

  • Administrator
  • VIP Member
  • *****
  • Posts: 1827
  • I want to show my performance at any where
    • View Profile
    • Higher Education
Generate Random Number of any digits using Visual Basic
« on: January 28, 2012, 09:00:30 AM »
Below is a brute force program to generate any number of Random values of given digits using Visual Basic. The code is specific for given input ( 26 Alphabets and 10 Digits).

Function generate_Number() As Integer
Dim values() As String = {“A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”, “I”, “J”, “K”, “L”, “M”, “N”, “O”, “P”, “Q”, “S”, “T”, “U”, “V”, “W”, “X”, “Y”, “Z”, “0″, “1″, “2″, “3″, “4″, “5″, “6″, “7″, “8″, “9″}
Dim temp As String
Dim i, j, limit As Integer
i = 0
j = 0
limit = 1000 ‘ Number of random values u need
For i = 0 To limit
temp = “”
Dim rand = New System.Random
Dim k As Integer
For j = 0 To 15
k = CInt(Int((35 * Rnd()) + 0))
temp = temp + values(k)
Next
Me.Text = temp
My.Computer.FileSystem.WriteAllText(“C:output.txt”, temp & vbNewLine, True)
Next
End Function
Acquire the knowledge and share the knowledge so that knowing,learning then sharing - all are the collection