469,128 Members | 1,384 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,128 developers. It's quick & easy.

how to ristrict user to open the multiple form

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
Nov 19 '05 #1
4 2745
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.
-----Original Message-----
"Ahsan" <ah***@it24.com> schrieb
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
Store the reference to the Form. If the reference is

Nothing, it is notopen, otherwise it is. Only allow to open it when it is not already open.Set it to Nothing when the Form gets closed by handling it's Closed event.

--
Armin

.

Nov 19 '05 #2
"Zahid" <mr******@hotmail.com> schrieb
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.

Nov 19 '05 #3
Hello,

"Ahsan" <ah***@it24.com> schrieb:
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
--
MVP VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 19 '05 #4
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
"Ahsan" <ah***@it24.com> wrote in message
news:95****************************@phx.gbl...
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

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.