Jump to content

Generate Random word


Recommended Posts

I found this topic by search.

There is this script

$string="a,b,c,d"
$Array=StringSplit($string,",")
$i=Random(0,UBound($Array)-1,1)
MsgBox(0,"Random",$Array[$i])

It's generates a random letter (a/b/c/d). The problem is that sometimes it generates the number "4". Why?

Can you give me better script for generating random word?

Link to comment
Share on other sites

I found this topic by search.

There is this script

$string="a,b,c,d"
 $Array=StringSplit($string,",")
 $i=Random(0,UBound($Array)-1,1)
 MsgBox(0,"Random",$Array[$i])

It's generates a random letter (a/b/c/d). The problem is that sometimes it generates the number "4". Why?

Can you give me better script for generating random word?

Because the person who wrote forgot that the first element in the array returned by StringSplit is in fact the count of elements in the array.

Just change Random(0...... to Random(1....

:)

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...