how to ristrict user to open the multiple form

A

Ahsan

How can i stop one VB.Net form to execute again when its
running already ?
in other words I don't allow the user to open one form
twice in my application

Suggestions please.

Thank you,
Ahsan
 
Z

Zahid

Hi,

Im new to VB.Net so can someone please tell me how to
store and retrieve a reference to a form?

Thanks in advance.
 
A

Armin Zingler

Zahid said:
Im new to VB.Net so can someone please tell me how to
store and retrieve a reference to a form?

Visual Studio.NET
Visual Basic and Visual C#
Reference
Visual Basic language
Tour through Visual Basic
Object oriented programming in Visual Basic


Link to the topic above for VS 200*3*:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB/vbcn7/html/vbconProgrammingWithObj
ects.htm

(see hints in my signature)


--
Armin

- Links might be split into two lines. Concatenate them using notepad.
- Links might require to add a ".nnnn" after the "2003FEB", e.g.
"2003FEB.1033" for localized versions.
- Links starting with "ms-help" are URLs for the document explorer (<F1>).
Paste them in the URL textbox and press enter. Using internal help (menu
extras -> options -> environment -> help), display the "Web" toolbar that
contains the textbox.
- The tree representing the table of contents has been translated from
localized (German) version. Excuse slight deviations.
 
H

Herfried K. Wagner

Hello,

Ahsan said:
How can i stop one VB.Net form to execute again when its
running already ?
in other words I don't allow the user to open one form
twice in my application

Why don't you disable the button/... after opening the form?

You can store a reference to the form (written from scratch):

\\\
Private m_TheForm As TheForm

Public Sub ShowTheForm()
If m_TheForm Is Nothing Then
m_TheForm = New TheForm()
AddHandler m_TheForm.Closing, AddressOf Me.TheForm_Closing
Else
MsgBox("Form already visible")
End If
m_TheForm.Show()
End Sub

Private Sub TheForm_Closing( _
ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs _
)
m_TheForm = Nothing
End Sub
///

Regards,
Herfried K. Wagner
 
J

Jerry

Aside from disabling the mechanism you have given your user to open the
form, ie. btnOpenForm.enabled = False, you could place a static variable
inside the form which will increment by one inside the constructor. The
variable will count the number of instances of the form. You can put code
inside the constructor to not create the new form if the variable is >= 0.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top