Solved

Generating A Random Char from A-Z and 0-9

Posted on 2004-09-30
2
642 Views
Last Modified: 2010-05-19
I would like to know how to generate a  random character consisting of the alphabet and numbers 0-9.

And then I would like to add 16 random characters to an array that I can use for a keycode.

        Dim strArray(15) As String
        Dim c As Char
        Dim i As Integer

        For i = 0 To 15
            strArray(i) = ""Random Char Generation Here.""
        Next
Can anyone give me a hand?
0
Comment
Question by:UberDeveloper
2 Comments
 
LVL 19

Accepted Solution

by:
Desp earned 125 total points
ID: 12197718
do you need sometihing like this:
Dim Rand As String = String.Empty
        Dim r As Random = New Random(DateTime.Now.Millisecond)

        Dim i As Int32

        For i = 0 To 15
            If r.Next(1, 3) = 2 Then

                Rand += (Microsoft.VisualBasic.ChrW(r.Next(48, 57)).ToString())
            Else

                Rand += (Microsoft.VisualBasic.ChrW(r.Next(65, 90)).ToString())
            End If
        Next

        MsgBox(Rand)
0
 
LVL 2

Author Comment

by:UberDeveloper
ID: 12197744
Yes, thank you its perfect.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now