zanderhack 0 Newbie Poster

Dear all,
I want to determine the frequency of numbers in ranges. So, instead of just determining the frequency of numbers with the elements 1-10 (see example below), I would like to determine the frequency of number that have been created between 1-5 and 6-10. An example result would be "there have been x28 responses between 1-5 and x12 responses between 6-10". How do I code this please ?
cheers
zander

Option Explicit
Option Base 1
Dim mResponses(40) As Integer

Private Sub Form_Load()
Dim x As Integer

For x = LBound(mResponses) To UBound(mResponses)
mResponses(x) = 1 + Int(Rnd * 10)
Next x
End Sub

Private Sub cmdPrint_Click()
Dim frequency(10) As Integer '10 elements
Dim x As Integer

Call Cls
Call Randomize

'Calculate results
For x = LBound(mResponses) To UBound(mResponses)
frequency(mResponses(x)) = frequency(mResponses(x)) + 1
Next x
Print "Rating" & Space(3) & "Frequency"
For x = LBound(frequency) To UBound(frequency)
Print Space(3) & x & vbTab & vbTab & frequency(x)
Next x
cmdPrint.Enabled = False
End Sub


cheers
zander

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.