Solved

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

Posted on 2004-09-30
2
641 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
Comment Utility
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
Comment Utility
Yes, thank you its perfect.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

15 Experts available now in Live!

Get 1:1 Help Now