哈希在#if,#else,#end if中表示什么? [英] What do the hash signs in #if, #else, #end if mean?

查看:91
本文介绍了哈希在#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天全站免登陆