473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 2820
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ceebaby via AccessMonster.com | last post by:
Hi All Here's hoping someone can help me with this. I have a report based on a query where the criteria for 4 of the fields is set from an unbound form. I want the user to be able to select any...
5
by: Neil | last post by:
"lyle" <lyle.fairfield@gmail.comwrote in message news:48c3dde7-07bd-48b8-91c3-e157b703f92b@f3g2000hsg.googlegroups.com... Question for you. I'm doing something similar, only, instead of opening...
5
by: billa856 | last post by:
Hi, My project is in MS Access 2002. In that I want to open one form multiple times. I put one button on my main form. Now whenever I click on that button than form will be open. Now when I...
1
by: Mohit | last post by:
Hi all, I am working on a windows based client server application with multiple forms. All forms are having custom title bars with no default bars. There is one main form. Some forms are opened up...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.