473,326 Members | 2,175 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,326 software developers and data experts.

Make code not execute for a Debug build

Tom
How can I make code not execute for a debug build, but do
execute for a production build?
I have code which prompts for an account and password when
the program starts up. It is a pain to have to answer that
when I repeatly run the program during debugging, but it
is desired by my client. Presently I just comment it out
when I am debugging, but I was wondering if there was a
more automatic way? Some type of conditional compilation
depending on the type of build?

On another note, I'd like to say that since I started
programming VB 6 weeks ago I have found this forum
incredibly useful. I've learned not only from the answers
to my questions but from others questions as well. I'd
like to thank the several of you who answer most of the
questions. It is incredibly helpful. You must put a lot
of time into it and it is incredibly useful as the
Microsoft documentation is so poor. Just out of
curisosity, what motivates you to put so much time into
helping people on this forum and what does the "MVP"
several of you have after your names mean?

Thanks,
Tom
Nov 20 '05 #1
7 1571
I have a similar situation with one of my applications. Username/Password. I hardcode these two values in the text properties of the text boxes when debugging. If you find a better way I would like to use it too.

B

"Tom" wrote:
How can I make code not execute for a debug build, but do
execute for a production build?
I have code which prompts for an account and password when
the program starts up. It is a pain to have to answer that
when I repeatly run the program during debugging, but it
is desired by my client. Presently I just comment it out
when I am debugging, but I was wondering if there was a
more automatic way? Some type of conditional compilation
depending on the type of build?

On another note, I'd like to say that since I started
programming VB 6 weeks ago I have found this forum
incredibly useful. I've learned not only from the answers
to my questions but from others questions as well. I'd
like to thank the several of you who answer most of the
questions. It is incredibly helpful. You must put a lot
of time into it and it is incredibly useful as the
Microsoft documentation is so poor. Just out of
curisosity, what motivates you to put so much time into
helping people on this forum and what does the "MVP"
several of you have after your names mean?

Thanks,
Tom

Nov 20 '05 #2
Pre-Processor Directives

#If DEBUG Then

'Do something

#End If
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Tom" <an*******@discussions.microsoft.com> wrote in message
news:2c*****************************@phx.gbl...
How can I make code not execute for a debug build, but do
execute for a production build?
I have code which prompts for an account and password when
the program starts up. It is a pain to have to answer that
when I repeatly run the program during debugging, but it
is desired by my client. Presently I just comment it out
when I am debugging, but I was wondering if there was a
more automatic way? Some type of conditional compilation
depending on the type of build?

On another note, I'd like to say that since I started
programming VB 6 weeks ago I have found this forum
incredibly useful. I've learned not only from the answers
to my questions but from others questions as well. I'd
like to thank the several of you who answer most of the
questions. It is incredibly helpful. You must put a lot
of time into it and it is incredibly useful as the
Microsoft documentation is so poor. Just out of
curisosity, what motivates you to put so much time into
helping people on this forum and what does the "MVP"
several of you have after your names mean?

Thanks,
Tom

Nov 20 '05 #3
* "Tom" <an*******@discussions.microsoft.com> scripsit:
How can I make code not execute for a debug build, but do
execute for a production build?


\\\
#If DEBUG THen
...
#Else
...
#End If
///

In the project properties, make sure the checkbox that defines the
'DEBUG' constant is checked.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
Bruin,
Another equivalent way to do this is to use custom constants. Within the build configuration properties of a projects properties under the build sub menu you can also define custom constants and their values to be used in the same way. By using a custom constant instead of the built in debug flag I am able to change the behavior in either debug or release mode.

For Example in the custom constants field (Debug configuration) enter SkipAnnoyingTasks=True
you can then use the same login
#IF SkipAnnoyingTasks=false
'prompt for credentials
#end if

"Herfried K. Wagner [MVP]" wrote:
* "Tom" <an*******@discussions.microsoft.com> scripsit:
How can I make code not execute for a debug build, but do
execute for a production build?


\\\
#If DEBUG THen
...
#Else
...
#End If
///

In the project properties, make sure the checkbox that defines the
'DEBUG' constant is checked.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #5
I had not used this. Interesting, however, Im not sure why this might be
favourable to simply using #If Debug, perhaps you can illuminate ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Bruin" <Br***@discussions.microsoft.com> wrote in message
news:1D**********************************@microsof t.com...
Bruin,
Another equivalent way to do this is to use custom constants. Within the build configuration properties of a projects properties under the build sub
menu you can also define custom constants and their values to be used in the
same way. By using a custom constant instead of the built in debug flag I
am able to change the behavior in either debug or release mode.
For Example in the custom constants field (Debug configuration) enter SkipAnnoyingTasks=True you can then use the same login
#IF SkipAnnoyingTasks=false
'prompt for credentials
#end if

"Herfried K. Wagner [MVP]" wrote:
* "Tom" <an*******@discussions.microsoft.com> scripsit:
How can I make code not execute for a debug build, but do
execute for a production build?


\\\
#If DEBUG THen
...
#Else
...
#End If
///

In the project properties, make sure the checkbox that defines the
'DEBUG' constant is checked.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #6
OHM,
#If DemoVersion Then
' save not allowed
#Else
' save allowed in the purchased version
#End If

Where you build two versions of your assembly, the Demo & the Purchased
version (conceptionally 4 versions: Release Demo, Release Purchased, Debug
Demo, and Debug Purchased).

Also if it wasn't mentioned in this thread the ConditionalAttribute is
handy.

<Conditional("FullVersion")> _
Public Sub FileSave()
#If FullVersion
' code to save a file only used in Full Version
#End If
End Sub

Then you can simply call FileSave and the call will be conditionally
included in your assembly, this is how all the methods on Debug & Trace
work, they all have a <Conditional("DEBUG")> attribute on them.

The #If FullVersion will remove the method body if you so choose...

Hope this helps
Jay

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:uo**************@TK2MSFTNGP11.phx.gbl...
I had not used this. Interesting, however, Im not sure why this might be
favourable to simply using #If Debug, perhaps you can illuminate ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Bruin" <Br***@discussions.microsoft.com> wrote in message
news:1D**********************************@microsof t.com...
Bruin,
Another equivalent way to do this is to use custom constants. Within
the build configuration properties of a projects properties under the build sub menu you can also define custom constants and their values to be used in the same way. By using a custom constant instead of the built in debug flag I am able to change the behavior in either debug or release mode.

For Example in the custom constants field (Debug configuration) enter

SkipAnnoyingTasks=True
you can then use the same login
#IF SkipAnnoyingTasks=false
'prompt for credentials
#end if

"Herfried K. Wagner [MVP]" wrote:
* "Tom" <an*******@discussions.microsoft.com> scripsit:
> How can I make code not execute for a debug build, but do
> execute for a production build?

\\\
#If DEBUG THen
...
#Else
...
#End If
///

In the project properties, make sure the checkbox that defines the
'DEBUG' constant is checked.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


Nov 20 '05 #7
Good point, had not thought of that !

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
OHM,
#If DemoVersion Then
' save not allowed
#Else
' save allowed in the purchased version
#End If

Where you build two versions of your assembly, the Demo & the Purchased
version (conceptionally 4 versions: Release Demo, Release Purchased, Debug
Demo, and Debug Purchased).

Also if it wasn't mentioned in this thread the ConditionalAttribute is
handy.

<Conditional("FullVersion")> _
Public Sub FileSave()
#If FullVersion
' code to save a file only used in Full Version
#End If
End Sub

Then you can simply call FileSave and the call will be conditionally
included in your assembly, this is how all the methods on Debug & Trace
work, they all have a <Conditional("DEBUG")> attribute on them.

The #If FullVersion will remove the method body if you so choose...

Hope this helps
Jay

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:uo**************@TK2MSFTNGP11.phx.gbl...
I had not used this. Interesting, however, Im not sure why this might be
favourable to simply using #If Debug, perhaps you can illuminate ?

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Bruin" <Br***@discussions.microsoft.com> wrote in message
news:1D**********************************@microsof t.com...
Bruin,
Another equivalent way to do this is to use custom constants. Within
the
build configuration properties of a projects properties under the build

sub
menu you can also define custom constants and their values to be used in

the
same way. By using a custom constant instead of the built in debug

flag I
am able to change the behavior in either debug or release mode.

For Example in the custom constants field (Debug configuration) enter

SkipAnnoyingTasks=True
you can then use the same login
#IF SkipAnnoyingTasks=false
'prompt for credentials
#end if

"Herfried K. Wagner [MVP]" wrote:

> * "Tom" <an*******@discussions.microsoft.com> scripsit:
> > How can I make code not execute for a debug build, but do
> > execute for a production build?
>
> \\\
> #If DEBUG THen
> ...
> #Else
> ...
> #End If
> ///
>
> In the project properties, make sure the checkbox that defines the
> 'DEBUG' constant is checked.
>
> --
> Herfried K. Wagner [MVP]
> <URL:http://dotnet.mvps.org/>
>



Nov 20 '05 #8

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

Similar topics

7
by: rednexgfx_k | last post by:
All, Problem Summary: I've running about 30 make table queries via VBA in Access 2000, and my database goes from 14,000k to over 2,000,000k. In addition, the longer the procedure runs, the...
46
by: Profetas | last post by:
Hi, I know that this is off topic. but I didn't know where to post. Do you comment your source code while coding or after coding. for example: you write a procedure and after it is...
3
by: Ed Sutton | last post by:
My solution contains multiple C# and C++ components as well as a deployment project. In my top-level C# WinForms application, I added references to some components by browsing to the...
7
by: Wysiwyg | last post by:
Is there any way besides adding a specific debug command line argument for the project to tell if an application is running in debug mode? Thanks! Bill
18
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My...
21
by: Chris Durkin | last post by:
I've got an ASP.NET website on my local box, set to compile to bin\Debug and bin\Release in debug and release modes. Both directories are populated with dlls, as the solution has been compiled in...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
10
by: Sourcerer | last post by:
I wrote this very simple code in .NET VC++. I compiled it on my system, and tried to run it on my friend's computer (he doesn't have the compiler). We both have Windows XP Professional. I have .NET...
3
by: =?Utf-8?B?QWRpbCBBa3JhbQ==?= | last post by:
I posted this question in vsnet.ide newsgroup about more than a week back but didn't get any single response yet therefore, reposting again same to several newsgroups. When I run my C#...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.