title: How to avoid repetition of the numbers (all numbers should be different from each other)
body: <p>How to insert another instruction to be able to avoid repetition of number as all the six numbers should be different from each other?</p>
  
  <p>Here is the code of my Visual Basic module:</p>
  
  <pre><code>Module Loto
  
      Sub Main()
          Dim Value1, Value2, Value3, Value4, Value5, Value6 As Integer
  
          Console.WriteLine("Example 3: To generate six numbers from 1 to 40")
          Console.WriteLine()
  
          'Initialize the random-number generator.
          Randomize()
  
          'Generate a random value between 1 and 40.
          'Int((HighestValue - LowestValue + 1) * Rnd) + LowestValue
  
          Value1 = CInt(Int((40 * Rnd()) + 1))
          Value2 = CInt(Int((40 * Rnd()) + 1))
          Value3 = CInt(Int((40 * Rnd()) + 1))
          Value4 = CInt(Int((40 * Rnd()) + 1))
          Value5 = CInt(Int((40 * Rnd()) + 1))
          Value6 = CInt(Int((40 * Rnd()) + 1))
  
  
          Do While (Value1 = Value2)
              Value2 = CInt(Int((40 * Rnd()) + 1))
          Loop
  
          Console.WriteLine("Random number generated is " &amp; Value1)
          Console.WriteLine("Random number generated is " &amp; Value2)
          Console.WriteLine("Random number generated is " &amp; Value3)
          Console.WriteLine("Random number generated is " &amp; Value4)
          Console.WriteLine("Random number generated is " &amp; Value5)
          Console.WriteLine("Random number generated is " &amp; Value6)
  
          Console.ReadLine()
      End Sub
  End Module
  </code></pre>