Global Variable

  • Thread starter Thread starter Mark A. Deal
  • Start date Start date
M

Mark A. Deal

If I store a value in the registry such as InDebugMode then I would like to
be able to store whether we are in DebugMode across the application. In
other words, I would like to use something like:

IF DebugMode THEN
LogFile.WriteEntry("We are in debug mode")
END IF

I would prefer to avoid hitting the registry every time.

Can anybody offer any advise?

Running Visual Studio .Net 2003.
Delphi Convert---Kicking and Screaming :~)

--
Mark A. Deal
Document & Data Solutions, LLC
http://www.docsol.com
Time Matters AIC
GhostFill Certified Consultant
 
Hi,

You could make a shared variable in a class for that.

The class

Public Class Defaults
Public Shared ReadOnly Property DebugMode() As Boolean
Get
Dim bDebug As Boolean = False
#If debug Then
bDebug=True
#End If
Return bDebug
End Get
End Property
End Class


To use

Trace.WriteLine(Defaults.DebugMode.ToString)



Ken
 
Create a module and declare the variable in there? Or create a class with a
Shared DebugMode property?
 
Mark A. Deal said:
I would like to be able to store whether we are in DebugMode
across the application.

IF DebugMode THEN
LogFile.WriteEntry("We are in debug mode")
END IF

If you want to know if you're currently debugging the code, use

If System.Diagnostics.Debugger.IsAttached Then
End If

If you want to know if you're running a Debug build of the program,
you can use conditional compilation:

#If DEBUG Then
#End If

Or, for a Boolean like this, you could just create a Global Boolean
Variable in a Module.

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top