Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Use of #

0

What is the "#" used for in "#If VBA7 Then" in the tutorial;   

Remove the Title Bar from a UserForm?

Answer
Discuss

Answers

0
Selected Answer

The pound sign initiates a line of code that is outside a procedure. The normal syntax would be 

If VBA7 Then

but if you type this at the top of a module it won't compile. It must be within a sub or function. But that isn't where the condition needs to be in this particular case. So, in order to resolve this conundrum Microsoft added the pound sign to enable this specific exception to the rule.

The point of the If statement is to load either PtrSafe or legacy versions of APIs depending upon your computer and your software. That was quite useful nearly a decade ago when the LongLong data type was first introduced. Today PtrSafe versions should be used unless you have either equipment or software that is older than ten years or, as is the case with the tutorial, you want to be sure that your program can run in such outdated environments.

Read more about this subject here: https://codekabinett.com/rdumps.php?Lang=2&targetDoc=windows-api-declaration-vba-64-bit

Discuss

Discussion

Thank you Variatus, very helpful
Julian (rep: 2) Jan 26, '21 at 12:54 am
Sorry about the messed-up link. The HTML on this site doesn't want to wrok the way I expect it to.
Variatus (rep: 4889) Jan 26, '21 at 6:47 am
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login