Public Class Form6

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim n, ans, count As Integer
        Randomize()
        ans = Int(Rnd() * 100) + 1
        count = 0
        While n <> ans And count < 5
            n = InputBox("猜猜看數字是多少？（1~100）")
            If n > ans Then MsgBox("猜錯了，再小一點")
            If n < ans Then MsgBox("猜錯了，再大一點")
            count = count + 1
        End While
        If count <> 5 Then
            MsgBox("猜對了！ya！")
        Else
            MsgBox("bye bye，下次再挑戰！")
        End If
        Label2.Text = ans
    End Sub

End Class
