|
-
Mar 7th, 2001, 11:01 AM
#1
Thread Starter
Lively Member
Hi all,
I need to know what is the default space occupied by a variant variable and its size?
And waht will be its space and size when u assign some value to the variant variable.
Pls reply ASAP.
Luv...........Ravindran
-
Mar 7th, 2001, 11:07 AM
#2
Lively Member
Hi,
A variant with a numeric value takes 16 bytes, with a string, takes 22 bytes + string lenght.
Steph
Virtually Impossible !
VB5 Entreprise (SP3) - VB6 Entreprise (SP4), MSSQL7, MSAccess, VBA, VBScript, ASP
-
Mar 7th, 2001, 11:07 AM
#3
Fanatic Member
You can use the Len function to retrieve this information..
Code:
Private Sub Form_Load()
Dim v As Variant
Debug.Print Len(v) ' returns 0
v = 15
Debug.Print Len(v) ' returns 2 (integer)
v = "JON"
Debug.Print Len(v) ' returns 3
End Sub
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Mar 7th, 2001, 11:16 AM
#4
Fanatic Member
Better yet use the LenB function....
Code:
Private Sub Form_Load()
Dim v As Variant
Debug.Print LenB(v)
v = 15
Debug.Print LenB(v)
v = "JON"
Debug.Print LenB(v)
End Sub
and I think steph meant that an integer value is 16 bits and 2 bytes.
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Mar 7th, 2001, 11:37 AM
#5
transcendental analytic
No, a variant is always that fat 16 byte, 128 bit, and for strings 22 bytes + string length * 2 bytes
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Mar 7th, 2001, 11:42 AM
#6
Fanatic Member
WOW! That SUCKS!!
So then the best advice would be to not use Variants?
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Mar 7th, 2001, 12:07 PM
#7
Hyperactive Member
>So then the best advice would be to not use Variants?
Yeah, if you know what type of data you`ll be dealing with, then using the appropriate type is faster and smaller.
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
|