Click here to Skip to main content
15,867,946 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My Question is ??? - How to count "listbox" items from index 10 to 20 ... like this => 10 11 12 13 14 15 16 17 18 19 20

but not like this one 0 1 2 3 4 ......20

- M Using this code but not achieved ....

For Index As integer = CInt(listbox1.items.count - 10) To 20 next

As Well this one but same prome ..

For Index As integer = 10 To Listbox1.items.count 20 next

index is always running from 0 to 20 but not from 10 to 20 ....

i m stuck over here, can one one plzz tell me what m doing wrong within above given code ....

need help ... thnxxs
Posted
Comments
Richard MacCutchan 4-May-15 6:11am    
Count = 20 - 10 + 1;
Member 10521418 4-May-15 6:37am    
you r saying like this :
for index as integer = listbox1.items.count = 20 -10+1
Richard MacCutchan 4-May-15 6:43am    
No I'm saying it is easy to count from 10 to 20; what is the problem?
Member 10521418 4-May-15 6:46am    
tell me the code using listbox as u said above the count start from 10 thats okk but not stop at 20 it goes on and on ... i have 200 item in listbox ...
Richard MacCutchan 4-May-15 12:33pm    
Why not edit your question and explain exactly what you are trying to do. Saying "count from 10 to 20" really does not make it clear.

1 solution

If you need items from 10 to 20 then use such numbers, e.g.
VB
For i as Integer = 10 to 20

On the other hand, if you need last 11 items, then write:
VB
Dim last as Integer = listbox1.Items.Count-1
For i as Integer = (last-10) to last 


Of course you have to check for edge cases.
 
Share this answer
 
Comments
Member 10521418 4-May-15 6:43am    
i want to count from 10 to 20 ... but how to write code for that using listbox ..
Ralf Meier 4-May-15 7:02am    
What makes you so sure that your posted code is not working right ?
Or the code-snippet in Solution 1 ?
Member 10521418 4-May-15 7:05am    
buz i m fetching the index and the index count from 0 to 20 but not from 10 to 20 ....
Member 10521418 4-May-15 7:11am    
nd if it counts from 10 ye goes above 20 and so on and over at my last index that is 200x
Member 10521418 4-May-15 13:46pm    
i have correct my code and there was a minor change over there .... but still thnxxs guys it was a small correction that i realized afterwards....

Solved ......

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900