【发布时间】:2018-02-02 00:42:01
【问题描述】:
当在 VBA 中为 excel 分配 freefile 返回给一个整数时,为什么所有将来引用这个整数的调用都需要在变量之前加上一个井号?
例如:
Dim fileName As String, textData As String, textRow As String, fileNo As Integer
fileName = "C:\test.txt"
fileNo = FreeFile 'Get first free file number
textData ="Hello World!"
Open fileName For Output As #fileNo
Write #fileNo, textData
Close #fileNo
为什么变量fileNo必须引用为#fileNo?这是我在这里找到的另一种类型声明方式吗?
Use of symbol # (hash) in VBA Macro
谢谢!
【问题讨论】:
-
开头的hashtag表示该变量包含一个类似句柄的文件。末尾的标签表示该变量包含
Double类型。 -
谢谢!我现在看到了区别。
-
我认为这只是 1960 年代原始 BASIC 解释器的语法遗留问题。