tags:

views:

30

answers:

1

Is it possible to assign a value to a class variable from inside a #IF DEBUG conditional? Basically what I want to do is conditionally execute some code from inside my main form load if I am running in DEBUG mode. I thought I would do something like:

Public Class Form1
  public DEB as Integer

#if DEBUG then
  DEB = 1
#else 
  DEB = 0
#endi if

Private Sub Form1_Load(....)

 if DEB=1 Then
   <do something>
 else
   <do something else>
 end if
....

However, it seems like you cannot assign a value to a variable. I'm obviously not understanding the scoping correctly. I cant seem to put the #if DEBUG inside the Load. Can somebody explain how to do this.

A: 

Why not just test the compilation constant directly? You are not gaining anything by testing an actual variable.

Public Class Form1

Private Sub Form1_Load(....)

#if DEBUG then
    <do something>
#else 
    <do something else>
#end if

End Sub

End Class
Christian Hayter
Good point...but it seems like DEBUG is not set when I run it. I know I am running in DEBUG mode though.
GregH
Figured it out...the Solution was defined as "Release" build even though the project was defined to build in DEBUG.
GregH