<< Prev        Next >>

ID : 118

#If ... #Endif

Function

To select a source code to compile according to specified conditions.

Syntax

#If condition 1
	Code 1
#Elif condition 2
	Code 2
#Else
	Code 3
#Endif

Guaranteed entry

Condition n
Designate a conditional expression.
Code n
Designate a source code.

Description

Select a source code to compile according to specified conditions.

If the condition 1 is not 0 (True), code 1 is compiled. Code 2 and code 3 are not compiled.

If the condition 1 is 0 (False), condition 2 is selected. If the condition 2 is not 0 (True), code 2 is compiled. Code 1 and code 3 are not compiled.

More than one set of #Elif condition 2...code 2 can be designated.

If the condition 1 is 0 (False), condition 2 is selected. If the condition 2 is 0 (False), code 3 is compiled. Code 1 and code 2 are not compiled.

State condition n according to the preprocessor format.

Related Terms

Attention

Example

'!TITLE "Condition Compile"
' Judge a value defined by macro and add a value to a variable

#Define TEST 10

Sub Sample_IfEndif

  Dim aaa As Integer

  aaa = 10

' If a macro name TEST is 0
#If TEST = 0

  aaa = aaa + 10

  ' Display aaa on the message output window
  PrintDbg aaa

' If a macro name TEST is 0 or more
#Elif TEST > 0

  aaa = aaa + 20

  ' Display aaa on the message output window
  PrintDbg aaa

' If a macro name TEST is 0 or less
#Else

  aaa = aaa + 30

  ' Display aaa on the message output window
  PrintDbg aaa

#Endif

End Sub

ID : 118

<< Prev        Next >>