Results 1 to 10 of 10

Thread: [RESOLVED] Beloved SSTabs

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Location
    Germany, New Zealand, now in Australia
    Posts
    143

    Resolved [RESOLVED] Beloved SSTabs

    Hi there,

    Due to me working on an application wich only has ONE Form with SSTabs it get rather crowded with the code. Now I would like to branch out with some of that SSTab code to one of my modules. Maybe somebody could help ???

    VB Code:
    1. Private Sub SSTab1_Click(PreviousTab As Integer)
    2. '---
    3.     Select Case SSTab1.Tab
    4.         Case 0: '--- TAB ONE (0).
    5.             code ............
    6.             code ............
    7.             [COLOR=Red]This would be the section I like to Call from a module ???[/COLOR]
    8.             SSTab1.TabEnabled(1) = True
    9.             SSTab1.TabEnabled(2) = False
    10.             SSTab1.TabEnabled(4) = False
    11.             SSTab1.TabEnabled(6) = False
    12.             SSTab1.TabEnabled(7) = False
    13.             [COLOR=Red]...................[/COLOR]
    14.             code ............
    15.             code ............
    16.  
    17.         Case 1: '--- TAB TWO (1).
    18.             code ............
    19.             code ............
    20.             [COLOR=Red]This would be the section I like to Call from a module ???[/COLOR]
    21.             SSTab1.TabEnabled(0) = True
    22.             SSTab1.TabEnabled(2) = True
    23.             SSTab1.TabEnabled(3) = True
    24.             SSTab1.TabEnabled(4) = False
    25.             SSTab1.TabEnabled(5) = True
    26.             SSTab1.TabEnabled(6) = False
    27.             SSTab1.TabEnabled(7) = False
    28.             [COLOR=Red]...................[/COLOR]
    29.             code ............
    30.             code ............
    31.             etc. etc.
    32.         End Select

    Thanks aktell

  2. #2
    Addicted Member
    Join Date
    Apr 2006
    Location
    USA
    Posts
    207

    Re: Beloved SSTabs

    How about this ?
    VB Code:
    1. Private Sub SSTab1_Click(PreviousTab As Integer)
    2.     'in your case statements
    3.     'format is controlName,TabEnabled state of tab1,State of tab2 ...
    4.     EnableTabs SSTab1, True, False, True, True, True, True, True
    5. End Sub
    6.  
    7. 'in a module
    8. Public Sub EnableTabs(SStab As SStab, Tab1 As Boolean, Tab2 As Boolean, _
    9. Tab3 As Boolean, Tab4 As Boolean, Tab5 As Boolean, Tab6 As Boolean, _
    10. Tab7 As Boolean)
    11.    
    12.     SStab.TabEnabled(0) = Tab1
    13.     SStab.TabEnabled(1) = Tab2
    14.     SStab.TabEnabled(2) = Tab3
    15.     SStab.TabEnabled(3) = Tab4
    16.     SStab.TabEnabled(4) = Tab5
    17.     SStab.TabEnabled(5) = Tab6
    18.     SStab.TabEnabled(6) = Tab7
    19. End Sub
    Keith_VB6

    If you have any further questions, just ask.
    If this solves things, then please mark the thread resolved.
    [Thread Tools] --> [Mark Thread Resolved]

  3. #3
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Beloved SSTabs

    you could also do the EnableTab sub like this - a bit more dynamic
    VB Code:
    1. Public Sub EnableTabs(ByVal oSSTab As SSTab, ParamArray blnTab() As Variant)
    2.     Dim N As Long
    3.     For N = LBound(blnTab) To UBound(blnTab)
    4.         oSSTab.TabEnabled(N) = blnTab(N)
    5.     Next N
    6. End Sub

  4. #4
    Addicted Member
    Join Date
    Apr 2006
    Location
    USA
    Posts
    207

    Re: Beloved SSTabs

    Hey bushmobile,

    I knew someone would suggest this. I actually tried that version but I like the auto-complete type feature when using named variables and booleans.

    There's always a ton of different ways to do things.

    See the picture below. It speeds up the coding.
    Attached Images Attached Images  
    Keith_VB6

    If you have any further questions, just ask.
    If this solves things, then please mark the thread resolved.
    [Thread Tools] --> [Mark Thread Resolved]

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Location
    Germany, New Zealand, now in Australia
    Posts
    143

    Re: Beloved SSTabs

    Hi there,

    Thanks alot, but both seem not to work at all I receive only "syntex" and "Argument not optinal" errors.

    Any other ideas ???

    Thanks aktell

  6. #6
    Addicted Member
    Join Date
    Apr 2006
    Location
    USA
    Posts
    207

    Re: Beloved SSTabs

    Both examples should work. What lines are causing the errors and what are the exact messages.

    Also, what version of VB are you using ?

    In my example, you would have to fill in a true or false for each tab. In bushmoble's you would only need one.
    Keith_VB6

    If you have any further questions, just ask.
    If this solves things, then please mark the thread resolved.
    [Thread Tools] --> [Mark Thread Resolved]

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Location
    Germany, New Zealand, now in Australia
    Posts
    143

    Re: Beloved SSTabs

    Hi there,

    I have used the code as per your copy I maybe do not understand the meaning of your comment "'format is controlName" but otherwise it should be OK.
    I get the Error Msg. Compile error: Argument not optional and it highlights the SSTab1_Click Sub. I use VB 6.0 Enterprise Edition with (SP5).

    With regards to the True/False input I have use it this way for the first Tab, and it should be different on every other Tab:
    VB Code:
    1. EnableTabs SSTab1, , True, False, , False, , False, False

    Thanks aktell

  8. #8
    Addicted Member
    Join Date
    Apr 2006
    Location
    USA
    Posts
    207

    Re: Beloved SSTabs

    With regards to the True/False input I have use it this way for the first Tab, and it should be different on every other Tab:

    visual basic code:
    EnableTabs SSTab1, , True, False, , False, , False, False
    Ok, using my code. I see the problem. As the code is, aguments are not optional. You need to supply a True or False for each tab.

    Here's an exaple using optional args.
    VB Code:
    1. 'in a module
    2. Public Sub EnableTabs(SStab As SStab, Tab1 As Boolean, Optional Tab2 As Boolean, _
    3. Optional Tab3 As Boolean, Optional Tab4 As Boolean, Optional Tab5 As Boolean, _
    4. Optional Tab6 As Boolean, Optional Tab7 As Boolean)
    5.    
    6.     SStab.TabEnabled(0) = Tab1
    7.     If Not IsMissing(Tab2) Then SStab.TabEnabled(1) = Tab2
    8.     If Not IsMissing(Tab3) Then SStab.TabEnabled(2) = Tab3
    9.     If Not IsMissing(Tab4) Then SStab.TabEnabled(3) = Tab4
    10.     If Not IsMissing(Tab5) Then SStab.TabEnabled(4) = Tab5
    11.     If Not IsMissing(Tab6) Then SStab.TabEnabled(5) = Tab6
    12.     If Not IsMissing(Tab7) Then SStab.TabEnabled(6) = Tab7
    13. End Sub
    Keith_VB6

    If you have any further questions, just ask.
    If this solves things, then please mark the thread resolved.
    [Thread Tools] --> [Mark Thread Resolved]

  9. #9
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Beloved SSTabs

    same principle for the ParamArray version:
    VB Code:
    1. Public Sub EnableTabs(ByVal oSSTab As SStab, ParamArray blnTab() As Variant)
    2.     Dim N As Long
    3.     For N = LBound(blnTab) To UBound(blnTab)
    4.         If Not IsMissing(blnTab(N)) Then oSSTab.TabEnabled(N) = blnTab(N)
    5.     Next N
    6. End Sub

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Location
    Germany, New Zealand, now in Australia
    Posts
    143

    Re: Beloved SSTabs

    Hi there,

    Well, finaly I had some time to test this code you guy's send here, and I found the mistake I made also.
    !!! Each Tab has to be address with True or False. I had before:

    This is the wrong way.
    VB Code:
    1. EnableTabs SSTab1, , True, True
    This is the right way.
    VB Code:
    1. EnableTabs SSTab1, True, True, True
    Attached a Zip File if somebody looks for something similar.
    Thanks alot again.

    aktell
    Attached Files Attached Files

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