-
Aug 5th, 2013, 03:42 PM
#1
Thread Starter
Member
[RESOLVED] Member Variables Declared Without DataTypes
Can anyone explain what declaring a member variable without a DataType does and if there is any benefits in doing this? I've always been told that all variables should be declared with their datatypes as this leads to improved code. But I've come across some code recently where there is a member variable without the datatype and would just like some more information.
Thanks
-
Aug 5th, 2013, 04:24 PM
#2
Re: Member Variables Declared Without DataTypes
It just declares it behind the scenes as a Variant. To some extent, whether a Variant is good or not is a matter of taste, although as I understand it, if performance is a concern, Variant isn't exactly the speediest datatype around. Personally, I can't stand Variants, and only use them when I absolutely have no alternative.
From a stylistic perspective, it is cleaner if you declare everything explicitly as a datatype... this is just good practice, as it makes it harder to accidentally make certain kinds of mistakes, such as sending a double to a function that expects an integer... if both are declared as variants, you could end up getting a bad result after deployment that you would have easily caught during development if you had explicitly declared the values.
-
Aug 5th, 2013, 05:07 PM
#3
Thread Starter
Member
Re: [RESOLVED] Member Variables Declared Without DataTypes
Thanks, I thought that it must have been using a variant but just needed it confirming. I also only use variants when absolutely needed because of the memory use.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|