Results 1 to 4 of 4

Thread: whats is the problem with my code?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    whats is the problem with my code?

    hi, im having problem with my code

    VB Code:
    1. 'TabStrip
    2. Private Sub ctlTabs1_TabClick(OldTab As Integer, NewTab As Integer)
    3.     If OldTab <> NewTab Then
    4.         StatusBar.Panels(1).Text = "BUSY"
    5.         pause (300)
    6.         Framer(OldTab).Visible = False
    7.         Framer(NewTab).Visible = True
    8.         Option1(1).Value  = 1
    9.         StatusBar.Panels(1).Text = "READY"
    10.     End If
    11. End Sub
    12. 'TabStrip
    13. Private Sub ctlTabs2_TabClick(OldTab As Integer, NewTab As Integer)
    14.     StatusBar.Panels(1).Text = "BUSY"
    15.     pause (300)
    16.     Me.Caption = "Tab Changed from " & OldTab & " to " & NewTab
    17.     Option1(2).Value  = 1
    18.     StatusBar.Panels(1).Text = "READY"
    19. End Sub
    20. 'TabStrip
    21. Private Sub ctlTabs3_TabClick(OldTab As Integer, NewTab As Integer)
    22.     StatusBar.Panels(1).Text = "BUSY"
    23.     pause (300)
    24.     Me.Caption = "Tab Changed from " & OldTab & " to " & NewTab
    25.     Option1(3).Value  = 1
    26.     StatusBar.Panels(1).Text = "READY"
    27. End Sub
    28. 'TabStrip
    29. Private Sub ctlTabs4_TabClick(OldTab As Integer, NewTab As Integer)
    30.     StatusBar.Panels(1).Text = "BUSY"
    31.     pause (300)
    32.     Me.Caption = "Tab Changed from " & OldTab & " to " & NewTab
    33.     Option1(4).Value  = 1
    34.     StatusBar.Panels(1).Text = "READY"
    35. End Sub

    i have 4 OptionButton, when i click the ctlTabs1 i wan't the Option1(1) is selected, then if i click cltTabs2 i wan't the Option1(2) will become selected.. and so on...

    what is the problem with my code?

    thanks..

  2. #2
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    417

    Re: whats is the problem with my code?

    Not sure if this is what you want. OK I have a tab control with 4 Tabs and also 4 option buttons. when I click tab1 option1(0) is selected click tab2 options1(1) and so forth
    VB Code:
    1. Private Sub TabStrip1_Click()
    2.     Option1(TabStrip1.SelectedItem.Index - 1).Value = True
    3. End Sub

    Hope that helps. if not upload your example so we can have a look
    When your dreams come true.
    On error resume pulling hair out.

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: whats is the problem with my code?

    It is not exactly clear how TabClick is being used. There is no such event for the TabStrip control. Are you calling it from the Click event. Regardless try this code.

    This assumes the Option1 control array indexes are from 1 to 4 (same as the Tab.Index) instead of the default 0 to 3.

    VB Code:
    1. Private Sub Form_Load()
    2.     'forces Tabstrip click event to fire
    3.     'Tag property is used to contain the index of the previous tab
    4.     TabStrip1.Tag = 0
    5.     TabStrip1.Tabs(1).Selected = True
    6. End Sub
    7.  
    8. Private Sub TabStrip1_Click()
    9.     Dim lngOldTab As Long
    10.     Dim lngNewTab As Long
    11.    
    12.     lngOldTab = TabStrip1.Tag
    13.     lngNewTab = TabStrip1.SelectedItem.Index
    14.    
    15.     If lngOldTab <> lngNewTab Then
    16.        
    17.         StatusBar1.Panels(1).Text = "BUSY"
    18.         pause (300)
    19.  
    20.         Framer(lngOldTab).Visible = False
    21.         Framer(lngNewTab).Visible = True
    22.        
    23.         'set the value of the Option button corresponding to the current Tab t o true
    24.         Option1(TabStrip1.SelectedItem.Index).Value = True
    25.        
    26.         Me.Caption = "Tab Changed from " & lngOldTab & " to " & lngNewTab
    27.         StatusBar1.Panels(1).Text = "READY"
    28.     End If
    29.    
    30.     TabStrip1.Tag = lngNewTab
    31. End Sub

  4. #4
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: whats is the problem with my code?

    Here is a shorter way of using the tab strip

    Make a tab strip, with as many frames as there are tabs
    VB Code:
    1. Private Sub tabstrip_Click()
    2.     Dim x As Integer
    3.     For x = 0 To Frame.Count - 1
    4.       Frame(x).Visible = False
    5.     Next x
    6.     x = tabstrip.SelectedItem.Index
    7.     Frame(x - 1).ZOrder 0
    8.     Frame(x - 1).Visible = True
    9.    
    10. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width