Results 1 to 4 of 4

Passing parameters to class modules

Threaded View

Mats Samson Passing parameters to class... 10-23-2011, 04:49 PM
Leith Ross Re: Passing parameters to... 10-24-2011, 10:43 PM
Mats Samson Re: Passing parameters to... 10-25-2011, 05:54 PM
Mats Samson Re: Passing parameters to... 10-26-2011, 03:44 AM
  1. #1
    Registered User
    Join Date
    07-09-2010
    Location
    Helsingborg, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    26

    Passing parameters to class modules

    Hello,
    Leith Ross showed me the other day a way of identifying the UserForm control in focus through the function:
    Function GetActiveControl() As Control
    
        Dim SelCtrl As Control
        Dim Ctrl As Control
    
            For Each Ctrl In MultiPage1.Pages(3).Controls
                If Ctrl.InSelection = True Then
                   Set SelCtrl = Ctrl
                End If
            Next Ctrl
        
            Set GetActiveControl = SelCtrl
    
    End Function
    
    MsgBox GetActiveControl.Name
    I’d like to take a step further and pass parameters to a class module and depending on which control (CommandButton) is pressed, take a different action.

    I have in the Initialize section of the multipage UserForm:
    Dim RtnButtons() As New NavBtnClass
    Dim RtnBtnCnt As Integer
    Dim RtnCtl As Control
    
    RtnBtnCnt = 0
    For Each RtnCtl In Trader.Controls
        If Left(RtnCtl.Tag, 3) = "Rtn" Then
            RtnBtnCnt = RtnBtnCnt + 1
            ReDim Preserve RtnButtons(1 To RtnBtnCnt)
            Set RtnButtons(RtnBtnCnt).RtnNavBtns = RtnCtl
        End If
    Next RtnCtl
    and in the NavBtnClass class module

    Private Sub RtnNavBtns_Click()
           ‘Return to Menu page
          Trader.MultiPage1.Value = 0    ‘ I want to change the "0" to a variable
    End Sub
    Is it possible to pass a parameter to the class module changing the Multipage1.Value?

    If I put a value in the Button Tag property I can use f.i. myTag=Right(Ctrl.Tag,1) to extract
    the MultiPage number I want this particular Button to direct me to, but I don’t know how to pass this parameter to the class module!

    Regards
    Mats
    Last edited by Mats Samson; 10-25-2011 at 06:03 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1