borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (WIDE AREA NETWORK PROGRAMS)Next Topic (Crystal REport Preferrable Version) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Single Instance of an Application ? Solved Topic
Poster Message
ahmad
Level: Master

Registered: 03-02-2003
Posts: 120

icon Single Instance of an Application ?

G.Day
I want to know how in VB we can limit  the Application to a single instance,no matter how many times the user click there should be only one instance executing
Thanks

____________________________
@#@#@

04-09-2006 at 09:59 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: Single Instance of an Application ?

Hi ahmad,
Just set your Project to run "Sub Main()" as startup. Then the first line of code can be :-

If App.PrevInstance Then
MsgBox "Program already open", vbInformation
End
End If

That will do the trick.



____________________________
multi-tasking - the ability to hang more than one app. at the same time.

04-09-2006 at 02:21 PM
View Profile Send Email to User Show All Posts | Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 530
icon Re: Single Instance of an Application ?

put this code in your Sub Main


Public Sub Main()
    If App.PrevInstance Then
        'stop execution since another instance of the application is
        'already running
        End
    Else
        'run your interface form
        frmMain.show
    End If
End Sub


____________________________
AndreaVB

04-09-2006 at 02:22 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
ahmad
Level: Master

Registered: 03-02-2003
Posts: 120
icon Re: Single Instance of an Application ?

Thanks Guys,it has worked very well


____________________________
@#@#@

06-09-2006 at 05:59 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : VB General : Single Instance of an Application ? Solved Topic
Previous Topic (WIDE AREA NETWORK PROGRAMS)Next Topic (Crystal REport Preferrable Version) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder