Can't reference a control added to a form?

I have a Public SubProcedure in which I pass a Form, a StatusStrip and a String variable. What I'm trying to do is attach the StatusStrip to the Form and it won't let me. Here is my code below.

        Public Sub ProcessMessages(ByVal frm As Form, ByVal sbr As StatusStrip, ByVal strMsg As String)
        Try
            frm.Controls.Add(sbr)

            If gblnMessageTimer = True Then
                frm.sbr.items(0).text = strMsg
            Else
                MessageBox.Show(strMsg, "User Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End If

        Catch ex As Exception
            strErr = "modMain/ProcessMessages() - " & ex.Message
        End Try
    End Sub
Screenshot.jpg
BlakeMcKennaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ken ButtersCommented:
the statusstrip is being added to the collection of controls, not to the form.
however, it looks like you already have addressability to the status strip...

try replacing this: frm.sbr.items(0).text = strMsg
with this : sbr.items(0).text = strMsg
0
lluddenCommented:
When you add a control to a form at runtime, it doesn't create the reference to the pointer like you are using.  You have to reference it through the controls collection.

If you to access it with something like:

frm.Controls(shr.name).text
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.