Code of shutting a your program down? menu

User Tag List

Results 1 to 15 of 15
  1. #1
    Neth'zul's Avatar Banned
    Reputation
    204
    Join Date
    Nov 2007
    Posts
    887
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Code of shutting a your program down?

    Is there any way to shut down your program lets say if your someone logged in as a guest.

    Would it be something like....

    Dim If UserNameTextBox1.Text = ("Guest") and PasswordTextBox1.Text = ("Guest") Then
    Some thing something
    EndIf

    Code of shutting a your program down?
  2. #2
    Gothian's Avatar Member
    Reputation
    249
    Join Date
    Jul 2006
    Posts
    496
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code is simply:

    End

    Soon you can find my projects at: www.termight.info

  3. #3
    Clain's Avatar Banned
    Reputation
    179
    Join Date
    Jan 2008
    Posts
    1,396
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Exit Sub - exits the current sub.
    Me.Close - closes the current form.
    And as Gothian said - End just stops execution.

  4. #4
    Neth'zul's Avatar Banned
    Reputation
    204
    Join Date
    Nov 2007
    Posts
    887
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes but how can I put it on a Timer, that is my question. Like in 1 hour it will me.close

  5. #5
    The Maffyx's Avatar Contributor

    Reputation
    249
    Join Date
    Feb 2007
    Posts
    1,186
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not totally sure what you're trying to do but you could add a timer to the form, set the tick length for an hour (600000 ) I think would be the right number. Then double click on the form, to go to the load section, and add Timer1.start (or w/e you named the timer). Then go back and double click on the timer you added, and then type me.close . I think that would work. Just an easy solution.


  6. #6
    Weekday's Avatar Contributor

    Reputation
    144
    Join Date
    Sep 2007
    Posts
    350
    Thanks G/R
    1/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1 hour is 3600 seconds Maffyx ...
    That would be (3600000) milliseconds as interval.

  7. #7
    Jens's Avatar Contributor
    Reputation
    179
    Join Date
    Sep 2006
    Posts
    251
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    create a thread and put the sleep/Exit() in it :>

  8. #8
    maclone's Avatar / Authenticator enabled
    Reputation
    2420
    Join Date
    Nov 2007
    Posts
    8,726
    Thanks G/R
    0/1029
    Trade Feedback
    0 (0%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The best way to close your app: Application.Exit
    Zomfg. And no, don't ask. - Dombo did it.

  9. #9
    Clain's Avatar Banned
    Reputation
    179
    Join Date
    Jan 2008
    Posts
    1,396
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jen sleeping the thread just like... pauses the program unless you know how to work with it

  10. #10
    The Maffyx's Avatar Contributor

    Reputation
    249
    Join Date
    Feb 2007
    Posts
    1,186
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Sicko View Post
    1 hour is 3600 seconds Maffyx ...
    That would be (3600000) milliseconds as interval.
    Ah true, I knew it would be something big like that, didn't really do the math :P


  11. #11
    Erra's Avatar Member
    Reputation
    10
    Join Date
    Apr 2007
    Posts
    69
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by The Maffyx View Post
    Ah true, I knew it would be something big like that, didn't really do the math :P
    Thing is; that's a number to big.

    However, what he could do instead is;
    Put the interval to 1000 (1 second/1000 milliseconds)
    Have a variable called 'countzor', that increases by 1 every time the timer ticks and then simply check if countzor >= 3600 then
    end

    Wish you the best of luck ;p

  12. #12
    Apoc's Avatar Angry Penguin
    Reputation
    1387
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/12
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, C# code since I'm being lazy.

    Code:
    public Form1()
    {
       Timer myTimer = new Timer(); // Create the timer.
       myTimer.Elapsed += myTimer_OnTick; // Set the method to handle the event.
       myTimer.Interval = 3600000; // Set it to tick once per hour
       myTimer.Start(); // Start it.
    
       InitializeComponents(); // Required winforms method.
    }
    
    public static void myTimer_OnTick(object source, ElapsedEventArgs e)
    {
       // You can add extra code here before closing the app.
       Application.Exit();
    }
    Enjoy.

  13. #13
    Clain's Avatar Banned
    Reputation
    179
    Join Date
    Jan 2008
    Posts
    1,396
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I converted it to VB for you... credits to Apoc lawl.

    Code:
    Public Sub New()
       Dim myTimer As New Timer() ' Create the timer.
       AddHandler myTimer.Elapsed, AddressOf myTimer_OnTick ' Set the method to handle the event.
       myTimer.Interval = 3600000 ' Set it to tick once per hour
       myTimer.Start() ' Start it.
    
       InitializeComponents() ' Required winforms method.
    End Sub
    
    Public Shared Sub myTimer_OnTick(ByVal source As Object, ByVal e As ElapsedEventArgs)
       ' You can add extra code here before closing the app.
       Application.Exit()
    End Sub

  14. #14
    Jens's Avatar Contributor
    Reputation
    179
    Join Date
    Sep 2006
    Posts
    251
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Clain View Post
    Jen sleeping the thread just like... pauses the program unless you know how to work with it
    the point of making the thread is to not pause the program... :l

    on the top of my head;

    Private Sub ding()
    Thread.Sleep(TimeSpan.FromHours(1))
    Application.[Exit]()
    End Sub

    Dim dong As New Thread(ding)
    dong.Start()

  15. #15
    Erra's Avatar Member
    Reputation
    10
    Join Date
    Apr 2007
    Posts
    69
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I use in my BG-leecher;
    Code:
    Private Sub tmrLeech_Timer()
    Seconds = Seconds + 1
    Label1.Caption = "Minutes: " & Seconds  60 & " Seconds: " & Seconds - ((Seconds  60) * 60)
    If Seconds >= 3600 Then
    End
    End If
    End Sub
    Though it plays an alarm instead of shutting down, lol. (the BG-leecher, that is)

    So what you do is; you put a label (or just remove the line that starts with label1) and call it Label1 (by default it will, lmeow), then add a timer and call it tmrLeech and simply put the code I wrote anywhere in the form's code (that is, if you double click tmrLeech to generate the start and end code, you'll have to remove those parts from the code I wrote)

    One more thing: you'll have to set Seconds to 0 in the Form_Load() event.

    Code:
    Public Seconds As Integer 'Put this in the top of the form, if that doesn't work, change public to private 'cuz I've forgotten which one to use lolx.
    
    Private Sub Form_Load()
    Seconds = 0
    End Sub
    Last edited by Erra; 08-23-2008 at 08:36 AM.

Similar Threads

  1. [Guide]Admin rights for your program.
    By snigelmannen in forum Programming
    Replies: 3
    Last Post: 01-14-2010, 05:48 PM
  2. Make a restriction for your program
    By Ebonesser in forum Programming
    Replies: 0
    Last Post: 06-19-2009, 04:59 PM
  3. Get your program to startup when Windows starts!
    By kikpp in forum Programming
    Replies: 18
    Last Post: 06-19-2009, 04:24 PM
  4. Replies: 22
    Last Post: 03-11-2009, 09:28 PM
  5. [Guide] Password protect your programs
    By warsheep in forum Programming
    Replies: 5
    Last Post: 07-04-2008, 03:48 AM
All times are GMT -5. The time now is 06:03 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search