By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,816 Members | 2,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,816 IT Pros & Developers. It's quick & easy.

Module accessing a forms controls

100+
P: 102
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.
Mar 20 '17 #1

✓ answered by IronRazer

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...
Expand|Select|Wrap|Line Numbers
  1. Module Module1
  2.     Public Sub DoSomething(gbx As GroupBox)
  3.  
  4.         gbx.BackColor = Color.Red 'access the GroupBox through the (gbx) parameter
  5.  
  6.     End Sub
  7. End Module
  8.  
Then from the Form, you would pass the GroupBox to the sub/function when you call it...
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  2.         Module1.DoSomething(GroupBox1)
  3.     End Sub
  4.  

Share this Question
Share on Google+
2 Replies


100+
P: 299
Absolutely. Just specify the groupbox like this within your module:
Expand|Select|Wrap|Line Numbers
  1. CurrentFY.gpb_PDF.Text
Mar 20 '17 #2

IronRazer
P: 82
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...
Expand|Select|Wrap|Line Numbers
  1. Module Module1
  2.     Public Sub DoSomething(gbx As GroupBox)
  3.  
  4.         gbx.BackColor = Color.Red 'access the GroupBox through the (gbx) parameter
  5.  
  6.     End Sub
  7. End Module
  8.  
Then from the Form, you would pass the GroupBox to the sub/function when you call it...
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  2.         Module1.DoSomething(GroupBox1)
  3.     End Sub
  4.  
Mar 21 '17 #3

Post your reply

Sign in to post your reply or Sign up for a free account.