VB中类似于C中"Sizeof"的功能函数是什么?

prowastrel 2003-10-30 10:03:29
RT
...全文
717 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
prowastrel 2003-10-30
  • 打赏
  • 举报
回复
sizeof的参数是类型。如果没有类似的,只有先定义变量再取了。

to:daliwan(百发百中大力丸)
[Visual Basic]
Overloads Public Shared Function SizeOf( _
ByVal structure As Object _
) As Integer
这个具体怎用?
射天狼 2003-10-30
  • 打赏
  • 举报
回复
len
馮強 2003-10-30
  • 打赏
  • 举报
回复
len()返回unicode的字符数

lenb()返回字节数,你的要求,应该用这个函数可以实现。
dicklee1214 2003-10-30
  • 打赏
  • 举报
回复
len——对字长
lenb——对字节长
nforcedzh 2003-10-30
  • 打赏
  • 举报
回复
应该是lenB()
daliwan 2003-10-30
  • 打赏
  • 举报
回复
.NET 框架类库

Marshal.SizeOf 方法 (Object) [Visual Basic]请参见
Marshal 类 | Marshal 成员 | System.Runtime.InteropServices 命名空间 | Marshal.SizeOf 重载列表
要求
平台: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family

.NET 框架安全性:

SecurityPermission 用于操作非托管代码。关联的枚举:SecurityPermissionFlag.UnmanagedCode。
语言
C#

C++

JScript

Visual Basic

全部显示


返回对象的非托管大小(以字节为单位)。

[Visual Basic]
Overloads Public Shared Function SizeOf( _
ByVal structure As Object _
) As Integer
[C#]
public static int SizeOf(
object structure
);
[C++]
public: static int SizeOf(
Object* structure
);
[JScript]
public static function SizeOf(
structure : Object
) : int;
参数
structure
要返回其大小的对象。
返回值
非托管代码中 structure 的大小。

异常
异常类型 条件
ArgumentException structure 不是一个 Marshal 类。
-或-

structure 为数组类型。

NullReferenceException structure 为空引用(Visual Basic 中为 Nothing)。

备注
返回的大小实际上是该非托管对象的大小。对象的托管大小可以不同。对于字符类型,这受应用于该类的 CharSet 值的影响。

要求
平台: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server family

.NET 框架安全性:

SecurityPermission 用于操作非托管代码。关联的枚举:SecurityPermissionFlag.UnmanagedCode。
请参见
Marshal 类 | Marshal 成员 | System.Runtime.InteropServices 命名空间 | Marshal.SizeOf 重载列表



--------------------------------------------------------------------------------

将文档反馈发送给 Microsoft

© 2002 Microsoft Corporation。保留所有权利。
palmkey 2003-10-30
  • 打赏
  • 举报
回复
Function LenB(Expression)
返回存储一个变量所需的字节数
海牛 2003-10-30
  • 打赏
  • 举报
回复
Len(···)

7,789

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧