|
-
Oct 5th, 2000, 08:04 PM
#1
Thread Starter
Addicted Member
Hi,
How do you get/return the size of a variable or object in
bytes.
Code:
example :
Public Sub Test
Dim Name as String
Dim Value as Long
Name = "John Black"
Value = SizeOf(Name)
End Sub
-
Oct 5th, 2000, 08:21 PM
#2
Lively Member
-
Oct 5th, 2000, 08:24 PM
#3
It's actually the Len function, not keyword .
It is used like this:
Code:
Dim Name As String
Dim Value As Long
Name = "John Black"
Value = Len(Name)
Debug.Print Value
-
Oct 5th, 2000, 08:43 PM
#4
Thread Starter
Addicted Member
Interger and Arrays
Will this work for Integers and Array?
-
Oct 6th, 2000, 09:31 AM
#5
Here is Data Type Summary from MSDN:
Code:
Byte 1 byte
Boolean 2 bytes
Integer 2 bytes
Long 4 bytes
Single 4 bytes
Double 8 bytes
Currency 8 bytes
Decimal 14 bytes
Date 8 bytes
Object 4 bytes (Any Object reference)
String (variable-length) 10 bytes + string length 0 to approximately 2 billion
String (fixed-length) Length of string 1 to approximately 65,400
Variant (with numbers) 16 bytes Any numeric value up to the range of a Double
Variant (with characters) 22 bytes + string length Same range as for variable-length String
User-defined (using Type) Number required by elements The range of each element is the same as the range of its data type.
Arrays of any data type require 20 bytes of memory plus 4 bytes for each array dimension plus the number of bytes occupied by the data itself. The memory occupied by the data can be calculated by multiplying the number of data elements by the size of each element. For example, the data in a single-dimension array consisting of 4 Integer data elements of 2 bytes each occupies 8 bytes. The 8 bytes required for the data plus the 24 bytes of overhead brings the total memory requirement for the array to 32 bytes.
A Variant containing an array requires 12 bytes more than the array alone.
-
Oct 6th, 2000, 11:25 AM
#6
transcendental analytic
LenB will return the exact size in bytes for UDT's and Variants.
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.
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
|