Arrays; searching

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gj785
    New Member
    • Nov 2006
    • 3

    #1

    Arrays; searching

    Ok so I've got this problem for a programming class; and I can't seem to figure it out.

    I've got a bunch of random numbers (say test scores). Now I need to program the code so that the user can enter a minimum and maximum score (in an input box) and then display how many matching numbers are in the range that they selected (display in a message box).

    Any help, please?
  • gj785
    New Member
    • Nov 2006
    • 3

    #2
    by the way, I'm using Microsoft Visual Studio 2005.

    Comment

    • willakawill
      Top Contributor
      • Oct 2006
      • 1646

      #3
      Originally posted by gj785
      by the way, I'm using Microsoft Visual Studio 2005.
      Hi you can copy this and make it work for your project. This is a vb6 solution;
      Code:
      'we are assuming the the values you are checking
      'are stored in arValues()
      Dim intLow As Integer
      Dim intHigh As Integer
      Dim intCount As Integer
      Dim intLoop As Integer
      
      intLow = CInt(txtLow.Text)
      intHigh = CInt(txtHigh.Text)
      
      For intLoop = 0 To UBound(arValues)
         If arValues(intLoop) <= To intHigh _
            AND arValues(intLoop) >= intLow Then
            intCount = intCount + 1
         End If
      Next intLoop
      
      'intCount now holds the number of values in between the two user choices

      Comment

      • gj785
        New Member
        • Nov 2006
        • 3

        #4
        Thanks for the help.

        I got it working some how.

        Comment

        Working...