Share via

Public Function not accessible in other forms?

OSVBNET 1,401 Reputation points
2022-05-27T21:37:29.577+00:00

Hello experts,
Any idea why this public function is not accessible in other forms?

Public Declare Function SetThreadExecutionState Lib "kernel32" (ByVal esFlags As EXECUTION_STATE) As EXECUTION_STATE
Public Enum EXECUTION_STATE
ES_AWAYMODE_REQUIRED = &H40
ES_SYSTEM_REQUIRED = &H1
ES_DISPLAY_REQUIRED = &H2
ES_CONTINUOUS = &H80000000
End Enum

So this usage is OK?

Form1.SetThreadExecutionState(Form1.EXECUTION_STATE.ES_CONTINUOUS)

or it's better to use the whole above code as private in each form?

  • Update: using it on other forms does not work, no effect, pretty confused :(

Thanks :)

Developer technologies | VB
0 comments No comments

Answer accepted by question author

Karen Payne MVP 35,606 Reputation points Volunteer Moderator
2022-05-28T10:30:57.847+00:00

Place it in a code module in your project and use it from there.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.