Lesson 2 Practice. Children's Guessing Game

Hi,

I am trying to get the Random Number Generator to work in this Practice.

I’ve dragged an Assign box into the Flowchart, created a new variable names Random but, I cannot seem to get the Random Number Generator command correct.

I am entering new Random().Next{0.1000} but it doesn’t work. In fact, I have tried a whole host of combinations without success. Please can anyone give me the correct command?

Thank you.

Vennie

Hi,
It’s
new Random().Next(0,1000)
Random.xaml (7.1 KB)

1 Like

Hi,

Thank you for your reply. However I have tried that and I’m still getting an error. Please see scree shot below.

Regards,

Vennie

I don’t see any screenshot.
Did you run my code?

yes I did and I get this error message "Compiler error encountered processing exception new Random().Next(0,1000) end of expression expected

Ah, just put a full stop at the end and now the error message says “identifier expected”?

No need of full stop.
Its a simple method. It should work
Its working fine for me .:roll_eyes:

Try this.
Right(Now.Millisecond.ToString,3)

Hi,

Thanks again for your response. I have tried both versions you sent me but neither of them work

Perhaps I have a technical issue?

Vennie

come on man…:neutral_face:
It’s very simple.
What could possibly go wrong in that .:stuck_out_tongue:
@ovi is there something do with uipath studio itself.(version updates)

@ddpadil Studio Community Edition updates automatically, so no :smiley:
@Vennie i would suggest to go through all the lessons, because there are walkthroughs and answers to every practical exercise

Morning,

Thank you both for your responses. Working through the lessons is what I am trying to do. This is the first practice on Lesson 2. I’ll check to see if there are any updates.

Regards,

Vennie

In your workflow you are still using { brackets. please replace it with small brackets “( )”

Int32 random_number = New Random().Next(0,1000) // will work.

or just download attached sample workflow and run it.
Main.xaml (7.2 KB)

Regards…!!
Aksh

Hi,

Thank you all for your help but, I have just this minute worked out resolved the problem.
I do though appreciate the help from all of you.

Regards,

Vennie

Hi Vennie -
Even I am facing the same issue. Used below code to create random number.
Int32 rnd= new Random().Next(1,1000)

Error: TYPE Random.Next() is not defined

What is the work around u did ?

By the way there are many benefits of playing a game like it improves our attention and concentration, enhances memory, etc. I think it is great task taken by you.

I am having the same problem. What did you do to get around it?

Hi Tony,

I’m really sorry but it was quite a while ago, and I don’t remember exactly. If the problem is with creating the random number generator, I think I Googled
the .net code.

Sorry I can’t be of more help.

Regards,

Vennie

Malcolm Venn

Senior Business Analyst – O2C

Projects and Business Support Team

Finance & Accounting

NHS Shared Business Services

(Tel) 07736 084 834

Short Dial 7288 4835

MeetMe 0800 328 3367 / Participant Code 45727055#

www.sbs.nhs.uk

**Shared Vision.**Better Together.

Think before you print - NHS SBS is committed to supporting sustainability

This email originates from NHS Shared Business Services Limited (NHS SBS). The email and any attachments may contain confidential information and may be subject to copyright
or other intellectual property rights. It is only for the use of the addressees. You may not copy, forward, disclose, save or otherwise use it in any way if you are not the addressee or responsible for its delivery.

If you receive this email by mistake, please advise the sender and cancel it immediately. NHS SBS may monitor the content of emails within its network to ensure compliance with its policies and procedures. Any email is susceptible to alteration and its integrity
cannot be assured - NHS SBS shall not be liable if the message is altered, modified, falsified, or edited.

new Random().Next(0,1000)
Copy the same code, it will work. You might have missed the brackets after Random.

Just faced the same problem.
As the previous answer couldn’t help me to solve it, I share what I had to do in order to makes it work.

First of all:
Change the variable Random from string to Int32.

Then: On the 2 Flow decision activities when you enter Guess = Random and Guess < Random replace them respectively by Guess = Random.ToString and Guess < Random.ToString

Normally with these modifications you can run the guessing game.