1
NN1 = Int((500 - 100 + 1) * Rnd + 100)
NN2 = Int((500 - 100 + 1) * Rnd + 100)
NN3 = Int((500 - 100 + 1) * Rnd + 100)
NN4 = Int((500 - 100 + 1) * Rnd + 100)

I assume that we can reduce this into

For i = 1 to 4
"NN" & i = Int((500 - 100 + 1) * Rnd + 100)
Next i

However, I am getting a compilation error. How do I rectify this?

1
  • 2
    Use a Dictionary or Collection. "NN" & i is not equivalent to a variable. Commented Apr 21, 2020 at 4:08

1 Answer 1

1
Dim NN() As Integer
For i = 1 To 4
NN(i) = Int((500 - 100 + 1) * Rnd + 100)
Next i

I would suggest using an Array instead of multiple Integers

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.