jeudi 30 janvier 2020

The same number is generated everytime (VB.net)

Every time I run this I keep getting 71, I've tried making it public, sharing it and several other things, but it won't work, I am trying to make a program that has the use guess a randomly generated number, but for some reason, it won't work properly in window app forms, and I can't put it under the button as that results in it changing every time. Plz help.

Public Shared Randomize()
Dim value As Integer = CInt(Int((100 * Rnd()) + 1))

Public Sub EnterBtn_Click(sender As Object, e As EventArgs) Handles EnterBtn.Click
    Dim entervalue As String = EnterTxt.Text
    Dim chances As Integer
    Select Case entervalue
        Case > value
            ResTxt.Text = "Too big"
            chances += 1
        Case < value
            ResTxt.Text = "Too small"
            chances += 1
        Case = value
            ResTxt.Text = "Well done, you got it in " & chances & " tries"
    End Select
End Sub

Private Sub ResTxt_TextChanged(sender As Object, e As EventArgs) Handles ResTxt.TextChanged

End Sub

Private Sub EnterTxt_TextChanged(sender As Object, e As EventArgs) Handles EnterTxt.TextChanged

End Sub



Aucun commentaire:

Enregistrer un commentaire