VB.NET provides a default instance of each form in a Windows Forms application, primarily for backwards-compatibility with VB6.
Default Object Instances Provided by My.Forms and My.WebServices (Visual Basic)[
^]
My.Forms Object[
^]
Working with Multiple Forms in Visual Basic .NET: Upgrading to .NET[
^]
So, when you reference
frmMain.something
, you're actually referring to the default instance of the class
frmMain
.
The same is
not done for user controls. An instance of a user control without a containing form would serve no purpose. And since the control could be used multiple times on multiple different forms, there would be no sensible way to pick a single "default" instance.
Instead, the user control will be exposed as
(one or more) members on the containing form. Each instance of the control will have an ID assigned, which you can change using the design view.
So, if your control instance is on the current form, with an ID of
billingManagement1
, you'd use:
billingManagement1.lblTry.Text = patientID.ToString()
If it was on
frmMain
:
frmMain.billingManagement1.lblTry.Text = patientID.ToString()