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
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
The code is simply:
End
Soon you can find my projects at: www.termight.info
Exit Sub - exits the current sub.
Me.Close - closes the current form.
And as Gothian said - End just stops execution.
Yes but how can I put it on a Timer, that is my question. Like in 1 hour it will me.close
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.
1 hour is 3600 seconds Maffyx ...
That would be (3600000) milliseconds as interval.
create a thread and put the sleep/Exit() in it :>
The best way to close your app: Application.Exit
Zomfg. And no, don't ask. - Dombo did it.
Jen sleeping the thread just like... pauses the program unless you know how to work with it
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
Sorry, C# code since I'm being lazy.
Enjoy.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(); }
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
What I use in my BG-leecher;
Though it plays an alarm instead of shutting down, lol. (the BG-leecher, that is)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
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.