Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please explain the use of the # sign preceding an IF statement 1

Status
Not open for further replies.

lestrope

Programmer
Oct 10, 2006
14
0
0
US
Below is a sample excerpt of code. I see a pound sign before the IF statement and I'd like a simple explanation as to why it is there.

Code:
#If MTS Then
    Implements ObjectControl
    Private mObjContext As ObjectContext
    Private Sub ObjectControl_Activate()
        Set mObjContext = GetObjectContext
    End Sub
    Private Function ObjectControl_CanBePooled() As Boolean
        ObjectControl_CanBePooled = True
    End Function
    Private Sub ObjectControl_Deactivate()
        Set mObjContext = Nothing
    End Sub
#End If

..And another example where it is used
Code:
#If DISPLAY Then
            MsgBox oConn.Errors.Item(Index).Number & ";" & oConn.Errors.Item(Index).Source & oConn.Errors.Item(Index).Description + ";" & oConn.Errors.Item(Index).NativeError & ";" & oConn.Errors.Item(Index).SQLState
#Else
            'MsgBox oConn.Errors.Item(Index).Description
            App.LogEvent oConn.Errors.Item(Index).Number & ";" + oConn.Errors.Item(Index).Source & oConn.Errors.Item(Index).Description + ";" & oConn.Errors.Item(Index).NativeError & ";" & oConn.Errors.Item(Index).SQLState
#End If

Any insight will help me out. I'm reverse engineering this class and I'm not sure of the significance of the pound sign. Most of my VB experience is in .NET and I've never seen it.

Regards,
Levi
 
It conditionally compiles the section of code - used often to compile only a certain section of code for a certain platform, or for debugging purposes.

If you have the VBS MSDN help files installed, then put the cursor on #IF and hit F1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top