It relies on the fact that VB removes Debug.Print statements from the compiled EXE. Use Debug.Print to print something that will cause an error. Divide by zero is simple enough.
Public Function IsCodeCompiled() As Boolean
On Error GoTo ErrorHandler
Debug.Print 1 / 0
IsCodeCompiled = True
Exit Function
ErrorHandler:
IsCodeCompiled = False
Exit Function
End Function
Tip Submitted By: David Hay
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.
