|
-
Oct 27th, 2000, 02:34 PM
#1
Thread Starter
New Member
ok, I used the code:
Declare Function ExitWindowsEx Lib "user32.dll" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Timer1_Timer()
Label1.Caption = Format(Time, "HH:MM:SS")
If Text1.Text = Label1.Caption Then
Call ExitWindowsEx(1, 0)
End If
End Sub
the problem I am running into is that it what let me declare the function as public. If I declare it as private, it won't run. By the way, this code is to have VB automatically shut down windows at a certain time. Any info is appreciated.
-
Oct 27th, 2000, 02:37 PM
#2
Fanatic Member
You can't declare things Public in a form. Add a module to your project and declare it as public in the module.
-
Oct 27th, 2000, 02:41 PM
#3
Guru
It is not because of the Private/Public thing.
You can make it Private and keep it in your form, or make it Public and move it to a module... Same thing.
It is set to shut down Windows when Timer1_Timer occurs, and Text1.Text contains the same as Label1.Caption (which is set to the current time in HH:MM:SS form immediately before that).
Are you sure all the above occurs?
-
Oct 27th, 2000, 02:58 PM
#4
Thread Starter
New Member
It still does nothing. I put the declaration in a module.
-
Oct 27th, 2000, 03:10 PM
#5
Guru
- Are you sure the Timer1 exists (and is a Timer)?
- Are you sure Timer1.Enabled = True?
- Are you sure Timer1.Interval isn't zero?
- Are you sure Label1 exists (and is a Label)?
- Are you sure Text1 exists (and is a TextBox)?
- Are you sure that every N milliseconds (N = Timer1.Interval), Label1.Caption changes to the current time in HH:MM:SS form? (You can use a Debug.Print to make sure the event is reached)
- Are you sure you typed that in Text1 exactly as it appears in Label1?
And finally...- Are you sure all that code (except the Declare maybe) appears in the same form, and this form is the one that contains the Timer1, Label1 and Text1?
After you have made sure that all these things are OK, it should work.
-
Oct 27th, 2000, 03:19 PM
#6
Thread Starter
New Member
Here is the code EXACTLY as it appears on the form:
Private Sub Timer1_Timer()
Timer1.Enabled = True
Timer1.Interval = 1
Label1.Caption = Format(Time, "HH:MM:SS")
If Text1.Text = Label1.Caption Then
Call ExitWindowsEx(1, 0)
End If
End Sub
still doesn't work, there is obviously something that I am overlooking that is holding this up.
-
Oct 27th, 2000, 03:58 PM
#7
Fanatic Member
You need to put the lines:
Code:
Timer1.Enabled = True
Timer1.Interval = 1
In the Form_Load event.
-
Oct 27th, 2000, 03:59 PM
#8
Guru
Or, in design mode, you can put 1 in the Interval property and True in the Enabled property. 
Either way, those two lines don't belong in Timer1_Timer.
-
Oct 27th, 2000, 07:13 PM
#9
Hyperactive Member
Originally posted by remiller1
Here is the code EXACTLY as it appears on the form:
Private Sub Timer1_Timer()
Timer1.Enabled = True
Timer1.Interval = 1
Label1.Caption = Format(Time, "HH:MM:SS")
If Text1.Text = Label1.Caption Then
Call ExitWindowsEx(1, 0)
End If
End Sub
still doesn't work, there is obviously something that I am overlooking that is holding this up.
I don't feel like the If statement is good...
If Text1.Text = Label1.Caption Then ???
Does Text1 contain a time to shutdown windows?
If so, try:
If Label1.Caption = Text1.Text Then
I think that is it...
-
Oct 28th, 2000, 07:07 AM
#10
Frenzied Member
Asaf, I don't think that makes sense...
so you say there's a difference between
2 + 3 = 8 - 3
and
8 - 3 = 2 + 3
I think they're pretty the same, they both turn out to be true.
hmmm so it doesn't matter if you say
Text1 = Label1
or
Label1 = Text1
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|