How to Generates 10 Alphanumeric Random Codes in

Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 960
The below program will help to do so

Imports System.Linq

Namespace ConsoleApplication1
Class Program
Private Shared Sub Main(args As String())
Dim str = GenerateTenRandomAlphanumericCode()
End Sub

Public Shared Function GenerateTenRandomAlphanumericCode() As String
Dim code As String = String.Empty

Dim chars = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890"
Dim random = New Random()
Dim result = New String(Enumerable.Repeat(chars, 10).[Select](Function(s) s(random.[Next](s.Length))).ToArray())
code = result
Return code
End Function
End Class
End Namespace

Comments or Responses

Login to post response