Hey

I want to generate 3 different types of arrays but 2 include a negative number and Im not really sure how to do that.

The first type should generate 0 to 2 (which works):

num = Int(Rnd() * (2 - 0 + 1)) + 0

Now I need one that generates -1, 0, or 1.
and another that generates -2, -1, or 0.

If someone could help me out quickly, thank you very much as it is driving me nuts.

I think a second later I just solved :P

This would generate 1, 0, -1:

num = Int(Rnd() * (2 - 0 + 1)) + -1

This would generate 0, -1, -2:

num = Int(Rnd() * 3 - 0 + 1) + -3

Correct?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.