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

How to pass data to public property in another form

Seth Schrock
Expert 2.5K+
P: 2,939
I'm using the following code to open a form based on its string name:
Expand|Select|Wrap|Line Numbers
  1. Function GetFormByName(ByVal FormName As String) As Form
  2.         Dim Fullname As String = Application.ProductName & "." & FormName
  3.         Return Activator.CreateInstance(Type.GetType(Fullname, True, True))
  4.     End Function
My problem is that I want to be able to pass a value to custom public property to the form that I just opened, but since this property isn't a member of the Form class, it doesn't allow me to pass it a value like the following:
Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form
  2. frm = GetFormByName("frmEmployees")
  3.  
  4. 'Error on this line
  5. frm.FormKey = 9
Is there a way to do this?
May 11 '16 #1
Share this Question
Share on Google+
1 Reply


Seth Schrock
Expert 2.5K+
P: 2,939
I found the solution. I use the CallByName Function.
Expand|Select|Wrap|Line Numbers
  1. CallByName(frm, "FormKey", CallType.Set, intFormID)
This works perfectly for what I need.
May 14 '16 #2

Post your reply

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