🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.basic.visual.misc
2 messages
2 total messages Started by Mirco Soderi Sat, 23 Nov 2002 12:42
Why this does not work?
#325
Author: Mirco Soderi
Date: Sat, 23 Nov 2002 12:42
58 lines
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!
Re: Why this does not work?
#326
Author: Duane Bozarth
Date: Sat, 23 Nov 2002 17:06
14 lines
1903 bytes

Mirco Soderi wrote:
> snip irrelevant code...
>
> ' *** TURN OFF PC ***
> Const EWX_SHUTDOWN = 1
> Dim ResLon As Long
> ResLon = ExitWindowsEx(EWX_SHUTDOWN, 0&)
> ' *** END TURN OFF CODE ***
> 

Probably a lack of privileges or some such...did you check the return
code?
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads