Rocket Software Homepage
Forum Home Forum Home > AccuTerm Knowledge Base (read only) > Scripting & Automation
  New Posts New Posts RSS Feed - The "Random" Random Function
  FAQ FAQ  Forum Search   Register Register  Login Login

The AccuTerm forum has moved. Go to community.rocketsoftware.com to register for the new Rocket forum.

Forum LockedThe "Random" Random Function

 Post Reply Post Reply
Author
Message
kbdav View Drop Down
Newbie
Newbie


Joined: July 12 2016
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote kbdav Quote  Post ReplyReply Direct Link To This Post Topic: The "Random" Random Function
    Posted: December 05 2017 at 8:34am
Can someone explain to me how this happens:

I set myVal equal to a random Integer between 0 and 3 by
myVal = Random(0%,3%)

and somehow the result in some cases is equal to 4...

Try this code:
Dim i As Integer, RndVal As Integer
For i = 1 To 1000
RndVal = Random(0%,1%)
Debug.Print RndVal
Next

Tell me how many 2's popup?

---------------

I know, I am old school using AccuTerm 2K2. But I'm not in charge of buying the software here.
Back to Top
PSchellenbach View Drop Down
Admin Group
Admin Group

Moderator

Joined: December 15 2003
Location: United States
Status: Offline
Points: 2150
Post Options Post Options   Thanks (0) Thanks(0)   Quote PSchellenbach Quote  Post ReplyReply Direct Link To This Post Posted: December 05 2017 at 12:41pm
Hi Keith -

Looks like there is a bug in the Random() function in the VBA scripting engine that AccuTerm uses. It looks like Random() returns a Long between Min and Max+1, instead of between Min and Max.

Thanks,

Pete

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.