Article View: comp.lang.basic.visual.misc
Article #327Why this code does not work properly?
From: Mirco Soderi
Date: Thu, 28 Nov 2002 18:32
Date: Thu, 28 Nov 2002 18:32
64 lines
3365 bytes
3365 bytes
*************************************************************
The following is the content of my Form1 module that includes 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 placed on Form1, and set minuti equal to the content of
text1 textbox... ***
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
' *** THIS IS THE CODE THAT *SHOULD* 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. In effect, this
program is composed by a module (the
Form1 one) and the code included in this module is the one given above and
nothing more;
2. I have tried to use this program on a Windows XP Home Edition operating
system and the problem is that the count-down is ok but when it arrives to
zero, it goes to -1 minuti and 59 secondi and *the computer is not turned
off*.
THANK YOU IN ADVANCE TO ALL THE ONES THAT WILL DECIDE TO HELP ME!
- Mirco Soderi -
Technical Details
Message-ID:
<CitF9.4457$fa.162981@news1.tin.it>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news.mailgate.org!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: 115e07,b109cc5f87de0a31,start X-Google-Attributes: gid115e07,public X-Google-Thread: 110e3b,b109cc5f87de0a31,start X-Google-Attributes: gid110e3b,public X-Google-Thread: 111c14,b109cc5f87de0a31,start X-Google-Attributes: gid111c14,public X-Google-Thread: 107824,b109cc5f87de0a31,start X-Google-Attributes: gid107824,public X-Google-Thread: 108062,b109cc5f87de0a31,start X-Google-Attributes: gid108062,public X-Google-ArrivalTime: 2002-11-28 10:32:03 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news.mailgate.org!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,japan.comp.lang.visual-basic,no.it.programmering.visual-basic Subject: Why this code does not work properly? Lines: 70 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: <CitF9.4457$fa.162981@news1.tin.it> Date: Thu, 28 Nov 2002 18:32:02 GMT NNTP-Posting-Host: 213.45.245.85 X-Complaints-To: newsmaster@tin.it X-Trace: news1.tin.it 1038508322 213.45.245.85 (Thu, 28 Nov 2002 19:32:02 MET) NNTP-Posting-Date: Thu, 28 Nov 2002 19:32:02 MET Organization: TIN