- ASP - Random Functions
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·What's New?
Mail List


Unique Random Letters
Some computers systems require that each letter in a password be unique. If you want to give that kind of look or would just prefer that all initial passwords that you issue new users to your site be unique then this is the script for you. A simple for next loop randomly chooses a number between 26 and 97 converts that to a letter and stores it in an array. A second for next loop compares the current selection to previous ones made and if it is not unique reselects until it finds a unique character. Refresh the output of this example a couple of times for a complete demonstration as each potential selection is written to the browser as well as the unique variable created.
View the Output
Text View
Print View
Mail this Link
Download the Code

<title> Random Letters)</title>
<body bgcolor="#FFFFFF">
Letters in the order they were selected:<br>
' Determines how many unique random letters to be produced
dim random_number, counter, check, unique_letters

' When passing a varible for an array use redim
redim random_letter(tot_unique)

' begin random function

' Begin a for next loop from one to the max number of unique letters
For counter = 1 to tot_unique

' select a number between 26 and 97
random_number = Int(26 * Rnd + 97)

' take the numeric and turn it into a character
random_letter(counter) = Chr(random_number)

' write out the current choice to the browser
response.write random_letter(counter) 

' For next loop to compare the values stored in the array to
' the new random value being assigned
for check=1 to counter-1
if random_letter(check)= random_letter(counter) then 

' If the current value is equal to a previous value
' subject 
end if

next ' Repeat loop to check values

next ' Repeat loop to assign values to the array

<ol><% 'write out the unique letters in a list for display
For counter = 1 to tot_unique 
response.write "<li>" & random_letter(counter) & "</li>"

' accumulate the array values to one varible
unique_letters=unique_letters & random_letter(counter)

next 'repeat loop for display/variable creation
Unique Random Letters:<br>
<%= unique_letters %>
Click <a href="<%= request.servervariables("script_name") %>">here</a> to refresh this page





ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement is hosted by
    Donate Food Online with a Mouse Click at
    Donate Land Online with a Mouse Click at
    © 1999 - 2018
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3