How can i get the compiled type, to show at runtime if the program is in release mode or in debug mode
thanks
Printable View
How can i get the compiled type, to show at runtime if the program is in release mode or in debug mode
thanks
Hi.
Check this thread : http://www.vbforums.com/showthread.p...ighlight=debug
There is a built-in compilation constant called DEBUG
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click #If DEBUG Then MsgBox("Debug mode!") #Else MsgBox("Release mode!") #End If End Sub
What does thous # means before the if then else
Quote:
Originally posted by Antonio Begue
What does thous # means before the if then else
#If DEBUG Then
MsgBox("Debug mode!")
#Else
MsgBox("Release mode!")
#End If
thous #
Its conditional compilation. The stuff in the #If section will only be compiled into the assembly if the condition or variable (DEBUG in this case) is defined and is True. Otherwise the code in the #Else portion is compiled in.
Try it for yourself...
VB Code:
#If QWERTY Then MsgBox("Poop!") #End If
Put that in the Load event of your form, and see if you see a msgbox. I bet you won't.
Then, put this at the top of your class...
VB Code:
#Const QWERTY = True
and run it again. I'll bet you see the msgbox this time.
:)
ok but why this work #IF DEBUG then and this not if DEBUG then
and where can i get a list of constants like DEBUG
Now I understand! That's very cool... you learn something everyday.Quote:
Originally posted by Antonio Begue
ok but why this work #IF DEBUG then and this not if DEBUG then
and where can i get a list of constants like DEBUG
When you write #If the intellisense takes over with a list of constants already defined.
well I think it is not only that you get a pre defined constants list, I think that the false part does not get compiled so you reduce the runtime proces
Cool, thanks. I've been looking for that.Quote:
Originally posted by crptcblade
There is a built-in compilation constant called DEBUG
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click #If DEBUG Then MsgBox("Debug mode!") #Else MsgBox("Release mode!") #End If End Sub
This question was raised by Mr. Polite some time ago, and my only answer was the one above.
I had read about a constant but I have not been able to find it...until now, that is...thanks.