I need to create some debug stuff in my code but I don’t want the debug controls or code to be included in the Final build and I do not want to have to comment it all out either.
I know you can create controls at runtime so how do I create a PushButton at runtime. I tried the following code in the Window.Open Event but the button does not appear:
#If DebugBuild
Dim d As New PushButton
d.Visible = True
d.Top = 0
d.Left = 0
d.Width = 90
d.Height = 20
d.Caption = "Debug Menu"
#EndIf
[quote=173801:@Charles Fasano]I need to create some debug stuff in my code but I don’t want the debug controls or code to be included in the Final build and I do not want to have to comment it all out either.
I know you can create controls at runtime so how do I create a PushButton at runtime. I tried the following code in the Window.Open Event but the button does not appear:
#If DebugBuild
Dim d As New PushButton
d.Visible = True
d.Top = 0
d.Left = 0
d.Width = 90
d.Height = 20
d.Caption = "Debug Menu"
#EndIf[/quote]
You need to first have one PushButton as a control set to be able to create new members that way.
Or to place one on a ContainerControl which you make a new instance with embedwithin.
There is no way to fulfill these requirements exactly. There will always be some residue left over in the built application, unless you remove the debug stuff manually.
Sure there is.
If there are NO references to a class (like a container control) in the compiled code the class will be stripped out.
So the embedding code Christian posted above needs to be wrapped in a #if DebugBuild / #endif.
Then when building a release there are (or should be) no actual references to the control & the container will be stripped and the code that existed in the #if debugbuild will not be compiled in as it won’t even exist.