Results 1 to 2 of 2

Thread: [2005] How to prevent multiple instances of the form

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    240

    [2005] How to prevent multiple instances of the form

    Hi to All!

    What must I do in order for me to prevent multiple instances of the form?

    This code still allows to have another instance of the form:

    Code:
                Dim frm As frmVolAgeWarranty
                '  If the instance still exists... (ie. it's Not Nothing)
                If Not IsNothing(frm) Then
                    '  and if it hasn't been disposed yet
                    If Not frm.IsDisposed Then
                        '  then it must already be instantiated - maybe it's
                        '  minimized or hidden behind other forms ?
                        frm = New frmVolAgeWarranty
                        frm.BringToFront()  '  Optional
                    Else
                        '  else it has already been disposed, so you can
                        '  instantiate a new form and show it
                        frm = New frmVolAgeWarranty()
                        frm.Show()
                    End If
                Else
                    '  else the form = nothing, so you can safely
                    '  instantiate a new form and show it
                    frm = New frmVolAgeWarranty()
                    frm.Show()
                End If

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: [2005] How to prevent multiple instances of the form

    Use it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width