#if、#else、#end if 中的井号是什么意思? [英] What do the hash signs in #if, #else, #end if mean?

查看:68
本文介绍了#if、#else、#end if 中的井号是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写代码来检查文件是否可以从 SharePoint 中签出,如果不是,则提醒用户并告诉他们该文件正在被其他人使用以及谁在使用它.

I'm writing code to check if a file is available to be checked out of SharePoint and, if it isn't, alert the user and tell them that the file is in use by someone else and who has it in use.

我在 http://www.xcelfiles.com/IsFileOpen 遇到了一段代码.html#anchor_37

该代码似乎可以在测试场景中使用,因此我计划根据我的目的对其进行调整.我无法理解某些语法.

The code seems to work in test scenarios so I am planning to adapt it for my purposes. I'm having trouble understanding some of the syntax.

#If Not VBA6 Then

'// Xl97

For i = j - 1 To 1 Step -1

    If Mid(strXl, i, 1) = Chr(0) Then Exit For

Next

i = i + 1

#Else

'// Xl2000+

i = InStrRev(strXl, strFlag1, j) + Len(strFlag1)

#End If

我了解代码的作用,但我不明白#"符号的意义.

I understand what the code does but I don't get the significance of the '#' symbol.

另一个例子:

hdlFile = FreeFile

Open strPath For Binary As #hdlFile

strXl = Space(LOF(hdlFile))

Get 1, , strXl

Close #hdlFile

google 很痛苦,因为它太模糊了.

It is a pain to google because it is so vague.

推荐答案

哈希符号代表一个预处理器命令,它们是在编译之前处理的命令,本质上是生成动态/条件代码.这些类型的命令通常在 C/C++ 等语言中用于管理跨平台编程技术.一种常见的用法是检查特定环境或平台(即 VBA、Windows、MacOSX 等),然后实现特定于平台的代码.

The hash symbols represent a preprocessor command, which are commands that are processed prior to compilation, essentially producing dynamic / conditional code. These types of commands are often used in languages such as C/C++ to manage cross-platform programming techniques. A common usage is to check for a particular environment or platform (ie. VBA, Windows, MacOSX, etc), and then implement platform-specific code.

http://en.wikipedia.org/wiki/Preprocessor

这篇关于#if、#else、#end if 中的井号是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆