Module accessing a forms controls

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sc5502
    New Member
    • Jun 2014
    • 102

    Module accessing a forms controls

    I have a form named CurrentFY that has a groupbox on it. The groupbox name is gpb_PDF. CurrentFY calls a module named Excel2PDF. Can I reference the gpb_PDF while in Excel2PDF and if it can how do I go about it?

    Thanks in advance.
  • Luk3r
    Contributor
    • Jan 2014
    • 300

    #2
    Absolutely. Just specify the groupbox like this within your module:
    Code:
    CurrentFY.gpb_PDF.Text

    Comment

    • IronRazer
      New Member
      • Jan 2013
      • 83

      #3
      You should pass the GroupBox control to the sub or function in the Module through a parameter. For example, in the Module you would add a parameter to the sub/function like this...
      Code:
      Module Module1
          Public Sub DoSomething(gbx As GroupBox)
      
              gbx.BackColor = Color.Red 'access the GroupBox through the (gbx) parameter
      
          End Sub
      End Module
      Then from the Form, you would pass the GroupBox to the sub/function when you call it...
      Code:
          Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
              Module1.DoSomething(GroupBox1)
          End Sub

      Comment

      Working...