Article View: comp.lang.basic.visual.misc
Article #325Why this does not work?
From: Mirco Soderi
Date: Sat, 23 Nov 2002 12:42
Date: Sat, 23 Nov 2002 12:42
58 lines
3349 bytes
3349 bytes
*****
The following is the content of my Form1 module, including some declarations
out of subroutine and just two subroutines.
*****
*** At module level, not included in any subroutine, I have the following:
***
Dim minuti As Integer
Dim secondi As Integer
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long,
ByVal dwReserved As Long) As Long
*** The following is a subroutine that enables a Timer to work after having
pushed on Button1 on Form1... ***
Private Sub Command1_Click()
minuti = Text1.Text
Timer1.Enabled = True
End Sub
*** ... and this is the timer that does a count-down and *should* turn off
the PC after having completed the count-down (minuti = 0) ***
Private Sub Timer1_Timer()
If secondi = 0 Then
minuti = minuti - 1
secondi = 59
Else
secondi = secondi - 1
End If
Text1.Text = minuti & "." & secondi
If minuti < 0 Then
' *** TURN OFF PC ***
Const EWX_SHUTDOWN = 1
Dim ResLon As Long
ResLon = ExitWindowsEx(EWX_SHUTDOWN, 0&)
' *** END TURN OFF CODE ***
End If
End Sub
---------------------------------------------
That's all. *Why this code is not correct?*
Important info:
1. This is the only code of this very simple program. Just a module (the
Form1 one) having only the code written above;
2. I have tried to use this program on a Windows XP Home Edition operating
system.
3. Please note that the code that does not work properly is *only* the one
that *should* turn off the PC. The count down works properly.
THANK YOU IN ADVANCE TO ALL THE ONES THAT WILL DECIDE TO HELP ME!
Technical Details
Message-ID:
<XIKD9.44568$744.1603397@news1.tin.it>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!bofh.it!news-out.tin.it!news-in.tin.it!news1.tin.it.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f94ee,7d442923ed2ccc4f,start X-Google-Attributes: gidf94ee,public X-Google-Thread: 110e3b,7d442923ed2ccc4f,start X-Google-Attributes: gid110e3b,public X-Google-Thread: 107824,7d442923ed2ccc4f,start X-Google-Attributes: gid107824,public X-Google-Thread: 10b997,7d442923ed2ccc4f,start X-Google-Attributes: gid10b997,public X-Google-Thread: 106fd2,7d442923ed2ccc4f,start X-Google-Attributes: gid106fd2,public X-Google-Thread: 115e07,7d442923ed2ccc4f,start X-Google-Attributes: gid115e07,public X-Google-Thread: 111c14,7d442923ed2ccc4f,start X-Google-Attributes: gid111c14,public X-Google-Thread: 108062,7d442923ed2ccc4f,start X-Google-Attributes: gid108062,public X-Google-ArrivalTime: 2002-11-23 04:44:06 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!bofh.it!news-out.tin.it!news-in.tin.it!news1.tin.it.POSTED!not-for-mail From: "Mirco Soderi" <mircosoderi@virgilio.it> Newsgroups: comp.lang.basic.visual.misc,cz.comp.lang.basic.visual,fj.comp.lang.visualbasic,free.it.programmazione.visualbasic,free.it.visual-basic,it.comp.lang.visual-basic,japan.comp.lang.visual-basic,no.it.programmering.visual-basic Subject: Why this does not work? Lines: 63 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: <XIKD9.44568$744.1603397@news1.tin.it> Date: Sat, 23 Nov 2002 12:42:31 GMT NNTP-Posting-Host: 212.171.207.141 X-Complaints-To: newsmaster@tin.it X-Trace: news1.tin.it 1038055351 212.171.207.141 (Sat, 23 Nov 2002 13:42:31 MET) NNTP-Posting-Date: Sat, 23 Nov 2002 13:42:31 MET Organization: TIN