title: Visual Basic - Counting the occurrence of numbers from a random array
body: <p>I need to use arrays and strings. The program should just search for 1 number which the user will enter (0-9). Here is my code below. It uses an array to get a random number, and it's testing the occurrences for each number. However it's not working, but I don't need it to test for every number anyway.</p>
  
  <p>The program must only test for the 1 number that the user requests. So if the random number that's generated is say.. '7417', and user user has chosen '7', then the program will report back there have been two sevens. I'm going to use a textbox 'txtEnter' to get the users number to search for. Can anyone help me? Thanks!</p>
  
  <pre><code>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Randomize()
    Dim ArrayNum(1) As Integer
    ArrayNum(0) = Int(Rnd() * 100000)
  
    lblDisplayNumber.Text = ArrayNum(0)
  
    Dim num As Integer
    txtEnter.Text = num
    Dim counts = From c In num.ToString()
                 Group By c Into Group
                 Select DigitGroup = New With {.Count = Group.Count(),
                                               .Digit = c, .Group = Group}
                 Order By DigitGroup.Count Descending
                 Select String.Format("There are {0} number {1}'s found.",
                                       DigitGroup.Count, DigitGroup.Digit)
    Dim message = String.Join(Environment.NewLine, counts)
  End Sub
  </code></pre>