Jump to content
Collins

how to generate random number between 100 and 1000

Recommended Posts

Collins

I need help in generating 5 random number between 100 and 1000 and then saving them result into a text file..

Share this post


Link to post
Share on other sites
czardas
Posted (edited)

Use a loop : For 1 To 5. You will need to use functions Random() and FileWriteLine() inside the loop. FileOpen() must be placed before the loop and FileClose() must be placed after the loop. Run the Help File examples for these functions and then try to write some code. Post your efforts here so we can offer advice on coding, or if you get stuck.

Edited by czardas
  • Like 1

Share this post


Link to post
Share on other sites
Collins

Can you help me with a code please?

Share this post


Link to post
Share on other sites
czardas
Posted (edited)

You must make an attempt to write the code yourself. Here's an example to get you started. Run the code and see what it does. Then modify it to get it to do what you want it to do.

Global $iRandom ; Declare a variable - to store the random numbers

; COMMENT - FileOpen goes here

For $i = 1 To 5
    ; generate a random integer between 7 and 23
    $iRandom = Random(7, 23, 1)
    MsgBox(0, "Message", "Random Number = " & $iRandom)
    
    ; COMMENT - Write $iRandom to file using FileWriteLine()
Next

; COMMENT - FileClose() goes here

 

Edited by czardas

Share this post


Link to post
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

×