Set variable with random number

Hi! An easy question. How can I set a variable with a random number?
Thank you for your help!

2 Likes

Hey @ANGLEZ

int variable1=new Random().Next(1,100) This expression generates a random number between 1 to 100.

Regards…!!
Aksh

16 Likes

Thank you for your quick response, but where can I put this expression? In an assign module? In the variable definition?

1 Like

that was typo error that was not . it was comma new Random().Next(1,100)

For your reference : Get Help from UiPath Support Services | UiPath

Regards…!!
AKsh

3 Likes

If the Random().Next() doesn’t work for you, there’s another solution is to use milliseconds.

Right(Now.Millisecond.ToString,2)

milliseconds are practically random.

8 Likes

Great! Both solutions are working
Thanks!

hi i don’t understand “int variable1=new Random().Next(1,100)” From where this syntax comes from? any language based. Coz Rpa is coding free of any language.

It uses principles set out in VB. Lots of jobs in UiPath can be made easier / simpler with some knowledge of VB

VB.NET sorry. Speedy typing.

Hi @preethivj

Indeed RPA is code free from the perspective of drag&drop activities in the Flowchart for example. The activities are steps of the process. So even if not having programming skills & experience, Business operations people(or people who understand some programming notions at a basic level) can be trained(via Academy or other trainings) in using the RPA tools and automating processes in a really short time.

thanku

its been mentioned in the conversation that .net libraries is more enough for working with RPA.i checked syntax used in RPA are in both visual basic and .net libraries.