Collins Posted June 2, 2018 Share Posted June 2, 2018 I need help in generating 5 random number between 100 and 1000 and then saving them result into a text file.. Link to comment Share on other sites More sharing options...
czardas Posted June 2, 2018 Share Posted June 2, 2018 (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 June 2, 2018 by czardas Collins 1 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Collins Posted June 2, 2018 Author Share Posted June 2, 2018 Can you help me with a code please? Link to comment Share on other sites More sharing options...
czardas Posted June 2, 2018 Share Posted June 2, 2018 (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 June 2, 2018 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now