function issue

why won't this code work?
   
   Function IsPrtROLnFormOpen(ByVal LnNum As Integer, ByRef IsOpened As Boolean)
        Dim frmPartsInv As System.Windows.Forms.Form

        Select Case LnNum
            Case 1
                frmPartsInv = WindowsApplication1.RO_PartsL1
            Case 2
                frmPartsInv = RO_PartsL2
            Case 3
                frmPartsInv = RO_PartsL3
            Case 4
                frmPartsInv = RO_PartsL4
            Case 5
                frmPartsInv = RO_PartsL5
            Case Else
                frmPartsInv = RO_PartsL1
        End Select

        If Application.OpenForms().OfType(Of frmPartsInv).Any Then
            IsOpened = True
            MessageBox.Show("Parts Inventory Data Form on Line " + CStr(LnNum) + " is ALREADY Opened")
        Else
            IsOpened = False
        End If
        Return IsOpened
    End Function

Open in new window

when the variable "frmPartsInv" is in the
"If Application.OpenForms().OfType(Of frmPartsInv).Any Then" is will not see the form as "OPENED" AT ALL
the intellisense in vb.net says it's in the list??? (of opened forms)

however when the line is"
"If Application.OpenForms().OfType(Of WindowsApplication1.RO_PartsL1).Any Then" it behaves fine
am I not referencing the variable "frmPartsInv" correctly?
 When LnNum is = 1 obviously
MBHEY131Asked:
Who is Participating?
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.

Rgonzo1971Commented:
HI,

Maybe

frmPartsInv = New WindowsApplication1.RO_PartsL1

Regards
0
MBHEY131Author Commented:
HI,
 Maybe
 frmPartsInv = New WindowsApplication1.RO_PartsL1
 Regards
++++++++++++++++++++++++++++++++++++++++++++

Settled on:

       Select Case LnNum
            Case 1
                If Application.OpenForms().OfType(Of RO_PartsL1).Count > 0 Then
                    IsOpened = True
                Else
                    IsOpened = False
                End If
 
And all was well!!

I will try your suggestion when time allows,
 Thank You
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
MBHEY131Author Commented:
ReWording of code
0
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.