Hey guys can u tell me an anwer of one basic question
what is the difference between String and String Variant
Printable View
Hey guys can u tell me an anwer of one basic question
what is the difference between String and String Variant
VB declares all variables as variant unless you declare them as something else.
There isn't really a string variant. It would be just a variant.
Variants waste memory.
A string holds text... a variant holds anything.. (Objects, Numbers, Arrays, Text)
so you can put a string in a variant.. but if you know it will be a string.. declare as a string. (Uses less memory)
You should NEVER use variants as they consume too much memory and working with variants is much slower then with a regular type variable. So remember to always declare your variables properly.
THanks a lot i got it
While variants (only if numbers are being used) are 16 bytes (128 bits), if a string is used in there, it becomes a string variant, and ends up being 22 bytes + word lenght! It would compute a whole lot slower than a regular string. So always declare your variables.