By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,593 Members | 2,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,593 IT Pros & Developers. It's quick & easy.

Arrays; searching

P: 3
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?
Nov 16 '06 #1
Share this Question
Share on Google+
3 Replies


P: 3
by the way, I'm using Microsoft Visual Studio 2005.
Nov 16 '06 #2

100+
P: 1,646
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;
Expand|Select|Wrap|Line Numbers
  1. 'we are assuming the the values you are checking
  2. 'are stored in arValues()
  3. Dim intLow As Integer
  4. Dim intHigh As Integer
  5. Dim intCount As Integer
  6. Dim intLoop As Integer
  7.  
  8. intLow = CInt(txtLow.Text)
  9. intHigh = CInt(txtHigh.Text)
  10.  
  11. For intLoop = 0 To UBound(arValues)
  12.    If arValues(intLoop) <= To intHigh _
  13.       AND arValues(intLoop) >= intLow Then
  14.       intCount = intCount + 1
  15.    End If
  16. Next intLoop
  17.  
  18. 'intCount now holds the number of values in between the two user choices
  19.  
Nov 16 '06 #3

P: 3
Thanks for the help.

I got it working some how.
Nov 16 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.