0

I am trying to generate a random number between 10 and 20 for my program but the numbers being generated are less than 1 and are to 2 decimal places e.g. 0.64, 0.34 etc..

Dim TrigB As Random
    Dim numberb As Integer
    TrigB = New Random
    numberb = TrigB.Next(10, 20)
    TrigRdmb.Text = numberb.ToString

what do i need to change so that it produces a number between 10 and 20

thanks

hasitha w
  • 3
  • 1
  • 2

1 Answers1

0

Except for the TrigB.Next(10, 20) which you should have written as TrigB.Next(10, 21) to make it inclusive of 20, your code is fine. For Random.Next will Return Integer

If you get value less than 1, then it is likely you call Random.NextDouble and not Random.Next.

Ian
  • 30,182
  • 19
  • 69
  • 107