• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 600
  • Last Modified:

hide TABS if not specified VB.NET 2003/2010

Hi Experts,
I work from a Winform with TabControl + 10 tabs.

my solution now has random tabs on form_load (thanks to previous solution)

Now i want to only limit/show only 5 of them random TABS at any one time. So randomize 10 tabs but only show 5.

Thanks,
Roberto
0
RobertoFreemano
Asked:
RobertoFreemano
  • 4
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Try something like:
Public Class Form1

    Private R As New Random
    Private tabs As New ArrayList

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each tp As TabPage In TabControl1.TabPages
            tabs.Add(tp)
        Next

        ShowRandomTabs(5)
    End Sub

    Private Sub ShowRandomTabs(ByVal number As Integer)
        TabControl1.TabPages.Clear()

        Dim temp As New ArrayList
        For Each tp As Object in tabs
            temp.Add(tp)
        Next

        Dim index As Integer
        For i As Integer = 1 to number
            If temp.Count > 0 Then
                index = R.Next(0, temp.Count)
                TabControl1.TabPages.Add(temp(index))
                temp.RemoveAt(index)
            End If
        Next
    End If

End Class

Open in new window

0
 
RobertoFreemanoAuthor Commented:
Hi Idle_Mind,

I get the following errors:
An unhandled exception of type 'System.NullReferenceException' occurred in mscorlib.dll

Additional information: [Resource lookup failed - infinite recursion detected.  Resource name: Arg_NullReferenceException]


&
There is no source code available for the current location. > 0000004c  mov         edi,dword ptr [eax+4]
0
 
RobertoFreemanoAuthor Commented:
Those errors are from 2003, but if I put this code into Visual Basic 2010 Express - it works fine.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
RobertoFreemanoAuthor Commented:
Hi Idle_Mind,

Do you think I should take a leap of faith in Visual Basic 2010 Express to continue developing in this from now on?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
I would...you can make your project target the .Net 2.0 framework which is on most machines.

Not sure what is causing that error in 2003.
0
 
RobertoFreemanoAuthor Commented:
Thanks Idle_mind ;)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now