Can I use conditional compilation to add missing types?

烂漫一生 提交于 2019-12-11 14:56:14

问题


The following:

#If False Then
    Public Type Long
        LoPart As Integer
        HiPart As Integer
    End Type
#End If

Throws a compiler error "Expected: Identifier" when run on my VBA7 32-bit office (Excel). This is because Long is a protected type. However, it was my understanding that the compiler should not see what's in the block (since the condition is always false).

Why do I still get the error?

I can still write and run code using Long variables - my type doesn't show up in intellisense. But the line

Public Type Long

remains red in the editor indicating some problem. Is it something to worry about?


NB, I'm trying to write a replacement for LongPtr for pre VBA7 systems where it didn't exist - in the off-chance that someone manages to run VBA6 in 64 bit office - I bet there's a way...

来源:https://stackoverflow.com/questions/56827029/can-i-use-conditional-compilation-to-add-missing-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!