Solved

Loop through Indexes in Descending Order

Posted on 2009-05-06
4
806 Views
Last Modified: 2012-05-06
I have 5 tabs (indexed at 0). Users select what options they want and then I remove the rest of the tabs from the end of the tabcontrol.  If they want to add a tab back they can do that also.
My problem is, I need to loop through the tabs in order to remove them.
Lets say a user has selected 4 items, 0 based, so I would need to remove 2 tabs.

As I loop through and remove the tabs, the last index is not longer available so I will get an error.
Is there a way to loop through the tabcount in descending order?

For Each i As Object In Me.lstChkSessions.CheckedItems
 

            s = Me.lstChkSessions.GetItemText(i).ToString

            ft.TabRacing.TabPages(c).Text = s

            Dim view As DataRowView = Me.lstChkSessions.CheckedItems(c)

            ft.TabRacing.TabPages(c).Tag = view.Item("SessionTypeID")

            c = c + 1
 

        Next i
 

        For p As Integer = c To ft.TabRacing.TabCount - 1

            ft.HideTab(ft.TabRacing.TabPages(p).Name)

        Next

Open in new window

0
Comment
Question by:Sheritlw
  • 3
4 Comments
 
LVL 15

Accepted Solution

by:
JackOfPH earned 500 total points
ID: 24321700
Try this code...
For p As Integer =  ft.TabRacing.TabCount - 1 to c step -1

            ft.HideTab(ft.TabRacing.TabPages(p).Name)

Next

Open in new window

0
 

Author Closing Comment

by:Sheritlw
ID: 31578834
Works great... Thanks
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24321802
Did it work?
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24321803
Glad I could help...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now