Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Loop through Indexes in Descending Order

Posted on 2009-05-06
4
Medium Priority
?
813 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

972 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