Solved

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

Posted on 2004-09-30
2
646 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 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