473,395 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Global Variable

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
Nov 21 '05 #1
3 1254
Create a module and declare the variable in there? Or create a class with a
Shared DebugMode property?

"Mark A. Deal" <no****@idaknow.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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

Nov 21 '05 #2
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
----------------
"Mark A. Deal" <no****@idaknow.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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

Nov 21 '05 #3
"Mark A. Deal" <no****@idaknow.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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.
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bryan Parkoff | last post by:
….I would like to know which is the best optimization to use global variable or global struct. I always tell C/C++ Compiler to turn on optimization. ….I use underscore between first name and...
4
by: Dan Elliott | last post by:
Hello, Converting from a working C program to C++, I run into the following error: I have a header: (header.h) namespace shared{ ... struct X{ ...
1
by: ravinder thakur | last post by:
hi all experts, i am porting a project from c to the c++ framework. during the porting i have encounterd a where i have a static and a global variable with the same name. now what rules c...
24
by: LP | last post by:
After a code review one coworker insisted that global are very dangerous. He didn't really give any solid reasons other than, "performance penalties", "hard to maintain", and "dangerous". I think...
9
by: Shapper | last post by:
Hello, I am declaring a variable in my aspx.vb code as follows: Public Class catalogue Public productid As String Private Sub Page_Load ... I have an image button where I call the...
53
by: fdmfdmfdm | last post by:
This is an interview question and I gave out my answer here, could you please check for me? Q. What are the memory allocation for static variable in a function, an automatic variable and global...
8
by: yinglcs | last post by:
Hi, I read this article about global variable in c: http://www.phim.unibe.ch/comp_doc/c_manual/C/SYNTAX/glo_int_vars.html But I have a few questions 1. how can I declare the global variable...
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
20
by: teddysnips | last post by:
Weird. I have taken over responsibility for a legacy application, Access 2k3, split FE/BE. The client has reported a problem and I'm investigating. I didn't write the application. The...
2
by: RgeeK | last post by:
I'm seeing something which make me think I'm missing something about how global var's behave. I've defined a global string, right at the start of my .py file. outXMLfile = "abc" I define a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.