![]() |
displaying random characters
ok here's something confusing the heck outta me. i'm making a random password generator of sorts, giving the user the option of numbers, lowercase letters, uppercase letters, or any combination thereof. there's more to the program than this obviously, but this is the relevant code i have set up to complete this task:
:
Function Random(Lowerbound As Long, Upperbound As Long)i don't know if anyone can understand what exactly i've done with the code or the role of all the variables, but allow me to tell you what happens as a result of execution: 1. a random number within the respective ASCII range (uppercase 65-90, lowercase 97-122) is stored in variable m or n. m corresponds to uppercase letters, n with lowercase letters. 2. a chr(m) and chr(n) statement (is supposed to) append the corresponding character or number to string 'output.' 3. string 'output' ends up consisting of a bunch of gibberish hash marks and non-alphanumeric characters. sometimes i do get actual numbers or text, but not often. so, any ideas as to why i'm not getting actual alpha/numeric output all the time? all i could find in my own research was somebody using a non-system font having this problem, but i tried terminal, times new roman, lucida console, ms sans serif; every default font i could think of but it didn't make a difference. i suspect there may be a problem with my randomize function...? thanks |
Your random-number function is a little dodgy - it should do this:
:
Random = Int(Rnd * (Upperbound - Lowerbound)) + Lowerbound + 1 |
i'll try that, thanks.
edit: ok, it DOES work now, and i've just realized that my code is utter crap and under perfect circumstances it wouldn't really make a random string anyway lol back to the drawing board... |
Don't forget to seed the generator:
randomize(timer) Best way of generating passwords in my opinion is to have a biggish text file of words (you can get all sorts with a little googling), and shove them together with a few other characters so you get more memorable things like south27cow and hello@cheese etc. |
I take it you had a free Period 3?
|
Quote:
|
It does exactly the same thing as just Randomize.
|
What it does is.... random (sorry)
|
I need a program created to generate phone # lists to be imported into a fax broadcasting program. The area code and exchange #'s are known, but I need a program to generate all of the possible combinations for the last four digits.
|
| All times are GMT -5. The time now is 11:27 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC