• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

what does the # mean in front of a line is it a comment??

i have a program im useing and it has # in front of the lines

the lines are pulled all the way to the left and not in structured as the others are

is this a sort of comment line and does not do anything inside to the next # line ie

# if this = that then
print to screen and move on
# end if

the lines are simmaler to the above (and i have found it does not do the instructions in the middle of the # lines too

is this the case it does not run the block??

thanks for enlightenment here
  • 2
2 Solutions
the #If...Then...#Else directives evaluate what is compiled by the compiler and not at run time.

Conditional compilation is typically used to compile the same program for different platforms. It is also used to prevent debugging code from appearing in an executable file. Code excluded during conditional compilation is completely omitted from the final executable file, so it has no effect on size or performance.
You can set conditional compilation constants in one of three ways:

1. In the Property Pages dialog box of the project (see constants under the BUILD menu)
2. At the command line when using the command-line compiler
3. In your code

Have a look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vacondeclaringconditionalcompilationconstants.asp
They are compiler conditional statements.

If the if statement is true, then the code between the condition is inlcuded the build.

So, for example the below code would only include the messagebox "I'm in debug" if the current ide is set to debug.
Otherwise its set to "I'm in release"

#If DEBUG Then
  MessageBox.Show("I'm in debug")
  MessageBox.Show("I'm in release")
#End If

You can also do this on procedures etc to.
The below code would opnly allow the RunME procedure to run if the InTestMode is true. Otherwise, all calls to the procedure will not function.

Public Class Form1
  #Const InTestMode = True

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  End Sub

  <Conditional("InTestMode")> Public Sub RunME()
  End Sub
End Class
JohnnyAuthor Commented:
oh hey thats neet ... thanks i thought i maybe a comment as php and others do...

thanks allot
now let me think on how to award the points....

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now