Click here to Skip to main content
15,892,809 members
Articles / Programming Languages / Visual Basic

Generate a Random String Key in VB.NET

Rate me:
Please Sign up or sign in to vote.
4.56/5 (22 votes)
27 Jul 20052 min read 186.9K   3.7K   31  
A slightly more intelligent random string generator.
Module Module1
    Sub Main()
        Dim KeyGen As RandomKeyGenerator
        Dim NumKeys As Integer
        Dim i_Keys As Integer
        Dim RandomKey As String

        ''' MODIFY THIS TO GET MORE KEYS    - LAITH - 27/07/2005 22:48:30 -
        NumKeys = 20

        KeyGen = New RandomKeyGenerator
        KeyGen.KeyLetters = "abcdefghijklmnopqrstuvwxyz"
        KeyGen.KeyNumbers = "0123456789"
        KeyGen.KeyChars = 12
        For i_Keys = 1 To NumKeys
            RandomKey = KeyGen.Generate()
            Console.WriteLine(RandomKey)
        Next
        Console.WriteLine("Press any key to exit...")
        Console.Read()
    End Sub
End Module

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions