WelcomeServicesPortfolioKnowledge BaseContact Us
27 Seconds, Inc.


Knowledge base View Article

need hosting?

Need hosting? We use and love our host - CrystalTech.com!
Need hosting? We use and love our host - CrystalTech.com!

Text Disguise - CAPTCHA-image/Human Interactive Proof web services

National Holiday Dates and Bank Holiday Dates - web site that provides the dates of national and bank holidays for the United States, United Kingdom, Ireland and Scotland

Holiday Web Service - web services for programmers to provide the dates of national and bank holidays in their applications for the United States, United Kingdom, Ireland and Scotland

Our Family Heart - web site to help families communicate no matter where they are

What?! You haven't heard about the greatest remote controlled flyer to come out in years?! Checkout the FlyTech DragonFly now!

Random string generator.

Summary: It isn't perfect, but it gives you a random string.
 
Keywords: CHARACTER
RANDOM
STRING
Applicable Software: Active Server Pages (ASP)
 
Body:

Many times we need to generate a random string of characters. Uses for it are filenames, order numbers and many other things.

Function randomString()
Dim m_iTMP
Dim m_iTimer
	m_iTimer = Timer()
Dim m_iPos
	m_iPos = InStr(1, m_iTimer, ".")

	If m_iPos > 0 Then
		m_iTMP = Left(m_iTimer, m_iPos - 1) & Right(m_iTimer, (Len(m_iTimer) - m_iPos))
	Else
		m_iTMP = CStr(m_iTimer)
	End If
	
	randomString = Left(Hex(m_iTMP) & Hex(m_iTMP) & Hex(m_iTMP), 6)
	
End Function

To use it, you would do:

Dim sRandomFileName
    sRandomFileName = randomString() & ".txt"

    Response.Write sRandomFileName

 
Author: Douglas L. Setzer, II, http://www.27seconds.com
Posted On: 3/5/2002 11:27:55 AM

Rate this article: Average: 2.5
n/a12345678910
Comments?

Article Search   |   All Articles

 

 
©2002 27 Seconds, Inc. All Rights Reserved.