0

I am trying to put two integers next to each other, but after some tries, I landed here and I can't get further. can you help me?

Dim max, min
max = 9
min = 0
Randomize
n1 = (Int((max-min+1)*Rnd+min))

max = 9
min = 0
Randomize
n2 = (Int((max-min+1)*Rnd+min))

x = MsgBox(n1, 1, "numbers")
x = MsgBox(n2, 1, "numbers")

numb = n1 + n2

x = MsgBox(numb, 1, "numbers")

I expect the two random generated numbers to be next to each other.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • 1
    Do you mean like high byte low byte? If you want to put two 8 bit integers into one 16 bit value, its low + (high * 256), if you just want to combine them as a string then CStr(n1) & CStr(n2) – SPlatten Aug 15 '19 at 11:17
  • 4
    `n1 & n2`?..... – GSerg Aug 15 '19 at 11:17
  • 3
    What GSerg said. `n1` and `n2` are integers, so the `+` operator will add them, not concatenate them as you seem to expect. Also, `Randomize` should be called only once. – Ansgar Wiechers Aug 15 '19 at 11:35

1 Answers1

2

GSerg brings the answer:

The line:

numb = n1 + n2

Should be changed to:

numb = n1 & n2

I hope this helped you!