Gathering data from multible tab indexes

MaestroRage

Member
Joined
Sep 30, 2008
Messages
5
Programming Experience
Beginner
I've been ripping my hair out for 2 days now and I finally gave in and admitted defeat. I have 3 forms for a GPA calculator i'm designing.

Mainform (has a tab control holding two CourseControllers)
CoursePanel (the core object to be used)
CourseController (has multiple CoursePanels and radio buttons etc)

Now what I want to do is have a function from MainForm that reads through the CoursePanels in CourseController and add them up into one variable. After that CourseController has been traversed, I want to then jump into the second CourseCountroller found on page 2 of the MainForm's tab menu, and again, gather necessary information.

At the end of the day, I should have traversed through both CourseController's and spit out a number. My difficulty is I can read through the first just fine, but when I tell the tab control to go to page 2, I still don't can't start getting information from there.

Please, any help would be GREATLY appreciated!

Here is some code that didn't work :/

Code:
Dim Inty As Integer = 0
        TabMenu.TabIndex = 0
        Inty = Inty + CourseController.PanelCycle(1)        
        TabMenu.TabIndex = 1
        Inty = Inty + CourseController.PanelCycle(2)
PanelCycle is supposed to go through each panel inside that course controller and tallies up scores. It is a function that returns the final number that is added onto Inty.
 

Robert_Zenz

Well-known member
Joined
Jun 3, 2008
Messages
503
Location
Vienna, Austria
Programming Experience
3-5
Hello

I can only provide you with some basic code, since you don't provide code for PanelCycle nor tell us what a CourseController is...

Basically you don't need to activate TabPages to gather data from the content. You can easily access each page with Me.TabPage1 etc. As every other control it has a Controls-Collection containing everything within there. If you don't know the TabPages by Design-Mode you can circle through them using the TabControls TabPage Collection.

Bobby
 

MaestroRage

Member
Joined
Sep 30, 2008
Messages
5
Programming Experience
Beginner
ah, my apologies, I didn't want to show you the messy chasm that is my code without absolute need. Essentially all I wanted to know was how to gather data from multiple tab pages.

I believe you have answered my question, I will try it out right away!
 

Tom

Well-known member
Joined
Aug 23, 2005
Messages
746
Programming Experience
5-10
Robert is correct in regards to how you can navigate the TabControl's TabPages but are you sure you even have too?

Say frmMain has a tabcontrol with 3 tabpages and one generic textbox on each tabPage; you can still access the info by calling TextBox1.Text, TextBox2.Text, TextBox3.Text anywhere in frmMain without calling each individual tabPage.
 

MaestroRage

Member
Joined
Sep 30, 2008
Messages
5
Programming Experience
Beginner
this is true, but what I have done here is made a custom controller with these panels in them. So the custom controller has Panel1, Panel2, Panel3

if I put this custom controller into multiple tabs, aren't they still technically Panel1, Panel2, Panel3? Or would VB automatically name them Panel1_2, Panel2_2, etc?
 

Tom

Well-known member
Joined
Aug 23, 2005
Messages
746
Programming Experience
5-10
You would need to reference each custom controller to access its individual controls but you still shouldnt need to reference each tabpage to get to those controls.

Val1 = CustomControler1.TextBox1.text & CustomControler1.TextBox2.text etc
Val2 = CustomControler2.TextBox1.text & CustomControler2.TextBox2.text etc
 

MaestroRage

Member
Joined
Sep 30, 2008
Messages
5
Programming Experience
Beginner
right you are Tom! I JUST realized this on my way home from the park *walking helps me think*. I almost had a stroke from the sheer weight of the realization.

I guess I just wasn't thinking object oriented enough.

Much thanks everybody.
 
  • Like
Reactions: Tom
Top Bottom