Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
problem is when i call this sub its create every time a new new instencse of form
but i want if frmcompanylist is opend then set focus to it and if
not opend then open a new instencse
and also every time i want to
set frmcompanylist =nothing

exp code:
VB
private frmcompanylist as companylistform   
Public Sub Show(ByVal FormName As String)
    Select Case FormName
         Case 
            If frmcompanylist Is Nothing Then
                Set frmcompanylist = New CompanyListForm
            End If
            frmcompanylist.Show 1
            Set frmcompanylist = Nothing
   end select
end sub
Posted
Updated 6-May-12 7:59am
v2

1 solution

It's difficult to tell from that small code fragment, but I think it is probably because frmcompanylist is an instance variable - it is created fresh for each version of the class you method is in. Try making it shared, and you should be sorted:
VB
Private Shared frmcompanylist As companylistform = Nothing
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900