I am a beginner and been trying this for a while. Basically a program generates a random number and user has to guess this number and he has 5 chances. There must be a function which only checks if user has entered the number before or not. If yes user enters again until it is different from numbers entered before. Below is what i have currently written..
Function dup(ByVal n As Integer, ByVal lop As Integer)
Dim temp(5), kill As Integer
If lop = 1 Then
temp(1) = n
ElseIf lop > 2 Then
For count = 1 To lop - 1
If n = temp(count) Then
kill = 1
count = lop - 1
Else
kill = 0
End If
Next
End If
Return kill
End Function
Sub Main()
Dim x As New Random
Dim num, guess, ans As Integer
num = x.Next(0, 10)
Console.WriteLine("NUMBER : " & num)
For count = 1 To 5
Console.WriteLine("ENTER YOUR GUESS")
guess = Console.ReadLine
ans = dup(guess, count)
If ans = 0 Then
If guess = num Then
Console.WriteLine("CONGRATULATIONS")
Else
Console.WriteLine("TRY AGAIN")
End If
ElseIf ans = 1 Then
Console.WriteLine("U HAVE USED THIS NUMBER. ENTER AGAIN")
count = count - 1
End If
Next
Console.ReadKey()
End Sub