6 Replies - 4439 Views - Last Post: 29 November 2010 - 06:46 AM

#1 Nikhil_07n   User is offline

  • The cheese stands alone..
  • member icon

Reputation: 54
  • View blog
  • Posts: 2,490
  • Joined: 09-January 09

Turn Off Monitor Using VB6

Posted 26 January 2009 - 06:12 PM

Description: Paste the following code in a standard module and then call 'procTurnOff' using a command button.This Code, when run, turns off the monitor.
'=========================================================================
' =========== Paste the lines below into a standard module ===============

Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long

Const SC_MONITORPOWER = &HF170&
Const MON_OFF = 2&
Const WM_SYSCOMMAND = &H112


Private Sub procTurnOff()

  SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MON_OFF

End Sub


'Now you can call the above procedure using a command button , say cmdTurnOff

'==============Add this code to the command button=======================

Private Sub cmdTurnOff_Click()

Call procTurnOff

End Sub

'====================End=================================================


Is This A Good Question/Topic? 0
  • +

Replies To: Turn Off Monitor Using VB6

#2 PRIYO   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 20-March 09

Re: Turn Off Monitor Using VB6

Posted 20 March 2009 - 11:17 PM

nice
Was This Post Helpful? 0
  • +
  • -

#3 senthilds08   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-November 09

Re: Turn Off Monitor Using VB6

Posted 18 November 2009 - 01:08 AM

Dear Friend its not working for me am using vb6 only
Was This Post Helpful? 0
  • +
  • -

#4 sushma2009   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 26-January 10

Re: Turn Off Monitor Using VB6

Posted 26 January 2010 - 12:30 AM

very nice
Was This Post Helpful? 0
  • +
  • -

#5 Meeran   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 02-July 10

Re: Turn Off Monitor Using VB6

Posted 06 July 2010 - 08:25 AM

dear friend can any one ans me what is the use of option explicit?
Was This Post Helpful? 0
  • +
  • -

#6 chris_24   User is offline

  • New D.I.C Head

Reputation: 10
  • View blog
  • Posts: 37
  • Joined: 29-November 10

Re: Turn Off Monitor Using VB6

Posted 29 November 2010 - 06:41 AM

to meeran, If used, the Option Explicit statement must appear in a file before any other source code statements. When Option Explicit appears in a file, you must explicitly declare all variables using the Dim or ReDim statements. If you attempt to use an undeclared variable name, an error occurs at compile time. Use Option Explicit to avoid incorrectly typing the name of an existing variable or to avoid confusion in code where the scope of the variable is not clear. If you do not use the Option Explicit statement, all undeclared variables are of Object type.
Was This Post Helpful? 0
  • +
  • -

#7 chris_24   User is offline

  • New D.I.C Head

Reputation: 10
  • View blog
  • Posts: 37
  • Joined: 29-November 10

Re: Turn Off Monitor Using VB6

Posted 29 November 2010 - 06:46 AM

to Nikhil, This is so professional. you are so intelligent. keep up beyond everything.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1