Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 6th, 2005, 01:37 PM
Authorized User
 
Join Date: Feb 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sajid_pk Send a message via Yahoo to sajid_pk
Default Generation of alphanumeric random characters

Hi Friends,

I want to generate 25 distinct randam alphanumeric characters in one ASP.NET page. I am using following code
private int GenerateRandomNumber(){
Thread.Sleep( 1 );
Random r = new Random(DateTime.Now.Millisecond);
int a=0;
while (!( (a>=48 && a<=57) ||(a>=65 && a<=90) ||(a>=97 && a<=122)))
{
a = r.Next(123);
intNumber += 1;
}
return a;}

But this function always produces same 25 characters. Any idea?
 
Old May 10th, 2005, 08:37 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubhav.kumar
Default

Hi,

What about replacing

a = r.Next(123);
 with

a=(new Random(DateTime.Now.Millisecond)).Next(123);

Cheers

Anubhav Kumar





Similar Threads
Thread Thread Starter Forum Replies Last Post
Random Number Generation i_shahid C# 2005 2 March 31st, 2008 10:50 PM
Regex and Alphanumeric matching? quantass BOOK: Beginning Regular Expressions 0 March 10th, 2007 11:34 AM
random file generation Ashleek007 Beginning PHP 1 February 24th, 2005 03:20 AM
Random Generation of Username and Password Prabhakar_dt Classic ASP Basics 2 August 31st, 2004 06:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.