Random numbers problem


#1

I am having difficulty using the RND function to randomly generate 10 numbers (1-10) to change the form and play a sound. I have used this code, but it does not seem to be working:
Sub Random
Dim Ret
Ret = Int(10 * Rnd) +1)

If Ret=1 Then ChangeForm(Form15)
PlaySound “elephant1.wav”

I have read the handbook, but it doesn’t seem to help my situation.
Does anyone have any suggestions to fix my code?
Thanks!


#2

You say there’s a problem, but you don’t actually say what it is.

That’s vital information for anyone to help.


#3

Greetings @AppStudioSupport! I am sincerely sorry I was unclear. My issue is that when I used the code above on a button to generate 10 random numbers (1-10) in order to randomly change the form and play a sound, nothing happened. I believe there is an error in my code, but I am unsure what the error is or how to fix it. I need help from someone advanced to tell me where my error was and how to fix it. Hopefully you understand my issue and can help my situation.

Thanks!


#4

Are there any messages in the Chrome Debugger window?

http://wiki.nsbasic.com/Console.log

You can also use the console.log() function to output tracing data to the Chrome Debugger.

http://wiki.nsbasic.com/Using_the_Chrome_Debugger


#5

Greetings!

There are several messages in the Chrome Debugger:

1.index.html:2463 Uncaught SyntaxError: Unexpected end of input

  1. index.html#/Form1:1 Application Cache Error event: Resource fetch failed
    (404) http://127.0.0.1:49193/Danilyn/Pictures/Danilyn/circus-tent

I will also send an image of the chrome debugger as an extra resource for
you.

Also, several of my buttons are not functioning properly. I have used the
code:
Function Image56_onclick()
ChangeForm(Form3)
End Function

But when I click the button, the form does not change. I am unsure whether
this particular issue is connected with the random issue, but reagrdless,
the form does not change.

I appreciate any advice/help you could give me.

Cheers,
Danilyn


#6

Greetings!
(I was told the email didn’t go through, so I sent it again just in case)

There are several messages in the Chrome Debugger:

There is an attached image of the Chrome Debugger so you can see all the
messages.

Also, several of my buttons are not functioning properly. I have used the
code:
Function Image56_onclick()
ChangeForm(Form3)
End Function

But when I click the button, the form does not change. I am unsure whether
this particular issue is connected with the random issue, but reagrdless,
the form does not change.

I appreciate any advice/help you could give me.

Cheers,
Danilyn


#7

These questions don’t appear to have anything to do with ‘Random number problem’. Could you post under a new subject?

PS. Always fix syntax errors first!


#8

Do you know there is an unmatched parenthesis at the end? It should be
Ret = Int(10 * Rnd) + 1