博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
#If...Then...#Else Directives
阅读量:6254 次
发布时间:2019-06-22

本文共 2722 字,大约阅读时间需要 9 分钟。

#If...Then...#Else Directives

Conditionally compiles selected blocks of Visual Basic code.

#If expression Then   statements[ #ElseIf expression Then   [ statements ]...#ElseIf expression Then   [ statements ] ][ #Else   [ statements ] ]#End If

Parts

expression
Required for
If and
ElseIf statements, optional elsewhere. Any expression, consisting exclusively of one or more conditional compiler constants, literals, and operators, that evaluates to
True or
False. Three conditional compilation constants are provided:
Config,
Debug, and
Trace.
Debug and
Trace are
Boolean datatypes and can be set in the Project Properties dialogue. When
Debug is defined, Debug class methods generate output to the
Output window. When it is not defined, Debug class methods are not compiled and no Debug output is generated. Similarly, when
Trace is defined, Trace class methods generate output to the
Output window. When it is not defined, Trace class methods are not compiled and no Trace output is generated.
Config is a string datatype, which corresponds to the current setting in the Configuration Manager.
statements
Required for
If statement block, optional elsewhere. Visual Basic program lines or compiler directives that are compiled if the associated expression evaluates to
True.
#End
If
Terminates the #
If statement block.

Remarks

On the surface, the behavior of the #If...Then...#Else directives appears the same as that of the If...Then...Else statements. However, the #If...Then...#Else directives evaluate what is compiled by the compiler, whereas the If...Then...Else statements evaluate conditions 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.

Regardless of the outcome of any evaluation, all expressions are evaluated using Option Compare Text. The Option Compare statement does not affect expressions in #If and #ElseIf statements.

Note   No single-line form of the
#If,
#Else,
#ElseIf, and
#End If directives exists; that is, no other code can appear on the same line as any of the directives.

Example

This example uses the #If...Then...#Else construct to determine whether to compile certain statements.

#Const CustomerNumber = 36#If CustomerNumber = 35 Then    ' Insert code to be compiled for customer # 35.#ElseIf CustomerNumber = 36 Then    ' Insert code to be compiled for customer # 36.#Else    ' Insert code to be compiled for all other customers.#End If

转载于:https://www.cnblogs.com/yangbin990/archive/2005/11/30/287446.html

你可能感兴趣的文章
DLL
查看>>
php中计算中文字符串长度、截取中文字符串
查看>>
android 屏幕适配
查看>>
trimpath javascript的学习
查看>>
PERL Net::SMTP
查看>>
shedloads 大量 2016-10-02
查看>>
用explain 对sql语句进行优化 建议用多对一的方式查询
查看>>
Maven经验分享(一)安装部署
查看>>
Druid使用起步—在javaWeb项目中配置监控
查看>>
Android中Cursor类的概念和用法
查看>>
jquery select2 4.0版本中,ajax请求数据无法选中
查看>>
mysql密码忘记或修改密码的解决办法
查看>>
超链接上的提示
查看>>
C++多进程并发框架
查看>>
第九章:SpringBoot日志——(默认配置)
查看>>
java 写文件的三种方法比较
查看>>
OrgChart(组织机构图) - Flex
查看>>
在bat 中启动shell。
查看>>
AALaunchTransition
查看>>
Windows小技巧 – Win+R提高Windows使用效率
查看>>