|
| Author |
Message |
Ken
Joined: 04 Oct 2007 Posts: 7
|
Posted: Mon Jun 18, 2007 8:10 am Post subject: determining size of data |
|
|
Hi All,
I have a type as follows
public type Employee
intEmpId as long
sEmpName as string
end type
public emp as Employee
now, i want to know the size of "emp".. is this possible in vb? is it
supports any such function to determine the no of bytes occupied by a "type?"
Thanks
Archived from group: microsoft>public>vb>syntax |
|
| Back to top |
|
 |
Norm Cook
Joined: 04 Oct 2007 Posts: 418
|
Posted: Mon Jun 18, 2007 10:55 am Post subject: Re: determining size of data |
|
|
"Ken" wrote in message@microsoft.com...
> Hi All,
>
> I have a type as follows
>
> public type Employee
> intEmpId as long
> sEmpName as string
> end type
>
> public emp as Employee
>
> now, i want to know the size of "emp".. is this possible in vb? is it
> supports any such function to determine the no of bytes occupied by a
"type?"
>
> Thanks
Debug.Print Len(emp)
Note that this is the length of the structure/udt, 4 for the long & 4 for
the string |
|
| Back to top |
|
 |
Jim Mack
Joined: 04 Oct 2007 Posts: 735
|
Posted: Mon Jun 18, 2007 1:45 pm Post subject: Re: determining size of data |
|
|
Ken wrote:
> Hi All,
>
> I have a type as follows
>
> public type Employee
> intEmpId as long
> sEmpName as string
> end type
>
> public emp as Employee
>
> now, i want to know the size of "emp".. is this possible in vb? is it
> supports any such function to determine the no of bytes occupied by a
> "type?"
What Norm said, but remember that Len() here gives you the length of the string pointer only, not including any string body. In other words, Len() doesn't tell you the length of the data if you write a variable of that type to a file.
--
Jim Mack
MicroDexterity Inc
www.microdexterity.com |
|
| Back to top |
|
 |
Bob Butler
Joined: 04 Oct 2007 Posts: 1081
|
Posted: Mon Jun 18, 2007 12:16 pm Post subject: Re: determining size of data |
|
|
"Jim Mack" wrote in message @TK2MSFTNGP06.phx.gbl...
>Ken wrote:
>> Hi All,
>>
>> I have a type as follows
>>
>> public type Employee
>> intEmpId as long
>> sEmpName as string
>> end type
>>
>> public emp as Employee
>>
>> now, i want to know the size of "emp".. is this possible in vb? is it
>> supports any such function to determine the no of bytes occupied by a
>> "type?"
>
>What Norm said, but remember that Len() here gives you the length of the
>string pointer only, not including any string >body. In other words, Len()
>doesn't tell you the length of the data if you write a variable of that
>type to a file.
also that it gives the length when used in file i/o operations and not the
actual length in memory;for that use LenB
type x
a as integer
b as long
end type
Len=6
LenB=8 because 2 padding bytes are inserted after the Integer to dword align
the Long |
|
| Back to top |
|
 |
Ken
Joined: 04 Oct 2007 Posts: 7
|
Posted: Thu Jun 21, 2007 7:27 am Post subject: Re: determining size of data |
|
|
Hi All
LenB() works!!
Thanks for reply.
"Norm Cook" wrote:
> "Ken" wrote in message
> @microsoft.com...
> > Hi All,
> >
> > I have a type as follows
> >
> > public type Employee
> > intEmpId as long
> > sEmpName as string
> > end type
> >
> > public emp as Employee
> >
> > now, i want to know the size of "emp".. is this possible in vb? is it
> > supports any such function to determine the no of bytes occupied by a
> "type?"
> >
> > Thanks
>
> Debug.Print Len(emp)
> Note that this is the length of the structure/udt, 4 for the long & 4 for
> the string
>
>
>
>
|
|
| Back to top |
|
 |
|