Search code examples
infinite-loop

Loop with a random


I made a little picker, it just says yes or not, but idk why it stucks in a loop i the While Here is it:

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Dim kk As Integer
    kk = CInt(Int(Rnd() * 100) + 1)

    While (kk <> 0 Or kk <> 1)
        kk = kk / 2
    End While

    lblSiNo.Text = kk.ToString

End Sub

If it's 1, is a Yes, if it's 0, is No


Solution

  • While (kk <> 0 Or kk <> 1)
    

    Every integer is different from 0 or 1, it can't be both equals to 1 and 0. Your predicate is always true.