While trying to define an Any() function like python's, I found that I couldn't name anything "Any".
Attempting to name a Function, Sub, Const, or variable any
will throw a syntax error and the VBA IDE will highlight it.
I know any not a particularly great name, but why is it throwing a syntax error? The only reason I could think of was that it might be a reserved keyword, but it's not.
You can't use a space, period (.), exclamation mark (!), or the characters @, &, $, # in the name. Name can't exceed 255 characters in length. Generally, you shouldn't use any names that are the same as the function, statement, method, and intrinsic constant names used in Visual Basic or by the host application.
To do this, click on 'Tools' and then click on 'Options'. In the options dialog box, make sure that the 'Auto Syntax Check' option is enabled. If the 'Auto Syntax Check' option is disabled, VBA will still highlight the line with the syntax error in red, but it will not show the error dialog box.
Answer: Variable names in Visual Basic are made up of letters (upper and lower case) and digits. The underscore character, "_", is also permitted. Names must not begin with a digit.
How Not Equal Works in Excel VBA? VBA Not Equal works exactly opposite to the logic of equal to operator. Equal to operator returns TRUE if the supplied test is satisfied is not, it will return FALSE. So, for example, if you say 10 = 10, it will return TRUE or else FALSE.
VBA (Visual Basic for Applications) is not VB.NET, even though they share the same "Visual Basic" monikor and a similar syntax. (The linked documentation is for VB.NET, not VBA.)
VB6 and VBA in Microsoft Office (eg. Access, Excel) handles Any
as a reserved word, and it cannot be used as an identifier:
You might also encounter errors if you use a reserved word to name a control, an object, or a variable. The error messages you receive don't necessarily tell you that a reserved word is the cause of the problem.
In VB.NET, however, there is no problem using Any
as a variable name or other identifier:
Dim Any as String = "Hello world!" 'works just fine in VB.NET
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With