select case loop for vb

How do I design a solution to determine how many words in the listbox fall within different ranges as defined below. the steps are,
(1) Loop through each word in the listbox
(2) Using a select case structure in the loop count how many words have lengths in the following ranges:  1-5, 6-10, over 10
(3) Output how many letters fall within each range.
bob sagetAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
This would loop through your listbox and use the select case:

For Each itm In YourListBox.Items
  Select Case itm.Length
    Case <= 5
      '/ do something here
    Case <= 10
      '/ do something here
    Case Else
      '/ do something here
  End Select
Next

I'm not sure what you mean by "output how many letters fall in each range". Do you mean you want a count of how many words in the listbox fall into those ranges? If so:
Dim countFive as Integer
Dim countTen as Integer
dim countElse as Integer

For Each itm In YourListBox.Items
  Select Case itm.Length
    Case <= 5
      countFive += 1
    Case <= 10
      countTen += 1
    Case Else
      countElse += 1
  End Select
Next

Msgbox("Five or Less: " & countFive.ToString & ", Ten or Less: " & countTen.ToString & ", Over 10: " & countElse.ToString)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bob sagetAuthor Commented:
thank you so much, that case statement helped out a lot
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.