Jump to content



Photo

Little help with Random


  • Please log in to reply
2 replies to this topic

#1 MattX

MattX

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 342 posts

Posted 14 January 2005 - 01:01 PM

I have used exsisting code in the help file to generate a random letter, I have added a loop too so it does it 8 times. My problem is [ and I have many ] is how do I get the $letter to increase so it adds all the letters together...? I hope that made sense - Basically I need a 8 letter only random password.

$i = 0 Do If Random() < 0.5 Then     $Letter = Chr(Random(Asc("A"), Asc("Z"))) Else     $Letter = Chr(Random(Asc("a"), Asc("z"))) Endif $i = $i + 1 Until $i = 8 Msgbox(4096, "Random Letters", $Letter)








#2 MattX

MattX

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 342 posts

Posted 14 January 2005 - 01:15 PM

Think I've done it - I found someone elses loop:

Dim $i = 0, $word = "" For $i = 1 to 10 If Random() < 0.5 Then     $Letter = Chr(Random(Asc("A"), Asc("Z"))) Else     $Letter = Chr(Random(Asc("a"), Asc("z"))) Endif $word = $word & $letter Next Msgbox(4096, "Random Letters", $word)


Still not 100% sure how the For and Next works in this.....

#3 herewasplato

herewasplato

    Most Senile Poster

  • Active Members
  • PipPipPipPipPipPip
  • 4,426 posts

Posted 14 January 2005 - 01:19 PM

Still not 100% sure how the For and Next works in this.....

<{POST_SNAPBACK}>

...you will get 10 random letters in the "word"...
change
For $i = 1 to 10
to
For $i = 1 to 16
and you will get 16 random letters in the "word"...

later.....
..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users