Access variable of child form


New member
Dec 6, 2008
Programming Experience
I have about 60 Child forms

Each have a variable with same name.

In Main form I want to set the value of the variable of the active child.

One way of doing that is like

Select Case Me.ActiveMdiChild.Name
Case "formName"

I donot want to do that as it involves writing many cases and I may miss some.

Is there some other way of doing it .

I tried

Dim O as Object = Me.ActiveMdiChil

O.VariableName= 0

and its various variants but its not working

Plz HelpMe.

One way to do this is using inheritance, you can define a base form that has that property and let all other forms inherit it rather than the standard Form class. Then you cast whatever form instance to the base type to access the base class property.
Another is to define an interface with that property and let all forms implement it. Then you cast whatever form instance to the interface type to access the interface property.

Object type and late-binding (ot any type) is also available if you turn off Option Strict, but then you loose all the goodiness of compiler/intellisense type support.
deanobravo, ActiveMdiChild property already returns the active child, and the type of object returned is Form. The question is how to access a property of a specific type when you only have a reference of the general type Form.