As other commenters have indicated, the 'boolean' comparison of numbers probably isn't doing what you think it's doing. You would need each case to compare its reel value with all other reel values which wouldn't make the syntax much shorter than your If
structure. There are various mathematical solutions (and the one proposed by Nathan_Sav's should work if your data is good).
However, you asked if there's a better way and, to keep the code simple, one way would be to assign the reel values to a results array or collection of some kind.
An obvious collection would be a Dictionary
which could contain the frequency count and number of each unique reel value. If you had declared your ReelNum
as an array then the code would be very short, but keeping your individual variables, you'd need your main Sub
and one other to build the Dictionary. So your main Sub would be:
Dim count As Dictionary(Of Integer, Integer)
count = New Dictionary(Of Integer, Integer)()
BuildResults(count, ReelNum1)
BuildResults(count, ReelNum2)
BuildResults(count, ReelNum3)
BuildResults(count, ReelNum4)
BuildResults(count, ReelNum5)
Select Case count.Values.Max()
Case 1 : Console.Write("None the same")
Case 2 : Console.Write("Two the same")
Case 3 : Console.Write("Three the same")
Case 4 : Console.Write("Four the same")
Case 5 : Console.Write("All the same")
Case Else : Console.Write("Who knows?")
End Select
And the building routine:
Private Sub BuildResults(ByRef count As Dictionary(Of Integer, Integer), ByVal newNum As Integer)
If Not count.ContainsKey(newNum) Then count.Add(newNum, 0)
count(newNum) = count(newNum) + 1
End Sub
I'm not sure if this is an educational project, but just in case it is, I've included a Select Case
so you can see how it works.