Public Declare Sub ZeroMemory Lib "KERNEL32" Alias "RtlMoveMemory" (dest As Any, ByVal numBytes As Long) ???这明显是个错误的API声明,自己试试看能不能用?
to Hassle() : ZeroMemory a(0),lenb(a) 这句当中的lenb(a)要出错阿,他好像是说类型不符。 to kikikaki(江海门户通天下): 对于我来说,不现实阿。还是仅限vb中吧。
Option ExplicitPrivate Declare Sub ZeroMemory Lib "kernel32.dll" Alias "RtlZeroMemory" (dest As Any, ByVal numBytes As Long)Private Sub Command1_Click() Dim a() As Byte ReDim a(0 To 9) As Byte ZeroMemory a(0), UBound(a) + 1 End Sub对不起各位,惭愧,惭愧!
to Hassle() : 我的是2维数组。。是不是要这样? redim a(0 to 9,0 to 5) as byte ZeroMemory a(0,0), (UBound(a,1) + 1)*(UBound(a,2) + 1)
不行阿~~~~~~~~~~ 运行第一次,他说:bad dll calling convention 中断调试,如果再继续,就出现: the memory could not be "read"...............
redim a(0 to 9,0 to 5) as byte 分配内存ZeroMemory a(0,0), (UBound(a,1) + 1)*(UBound(a,2) + 1) a(0,0)是首指针,(UBound(a,1) + 1)*(UBound(a,2) + 1)计算清零的范围上面的应该没问题bad dll calling convention 没看过代码, 不敢乱说
干什么要erase了再redim???????????
直接Redim不就是清零吗? 干什么要copymemory??????????????
拿什么Copy?是不是Copy前要再Redim一个同样大小的数组?一连串的???????????????????????????????????????????
想不通!
数组是清零了。但是没用!!
有没有其他办法?
redim a(0 to 9) as byte
ZeroMemory a(0),lenb(a)
-------------------------------------
用汇编做个dll,在程序中调用
???这明显是个错误的API声明,自己试试看能不能用?
ZeroMemory a(0),lenb(a) 这句当中的lenb(a)要出错阿,他好像是说类型不符。
to kikikaki(江海门户通天下):
对于我来说,不现实阿。还是仅限vb中吧。
Dim a() As Byte
ReDim a(0 To 9) As Byte
ZeroMemory a(0), UBound(a) + 1
End Sub对不起各位,惭愧,惭愧!
我的是2维数组。。是不是要这样?
redim a(0 to 9,0 to 5) as byte
ZeroMemory a(0,0), (UBound(a,1) + 1)*(UBound(a,2) + 1)
运行第一次,他说:bad dll calling convention
中断调试,如果再继续,就出现:
the memory could not be "read"...............
分配内存ZeroMemory a(0,0), (UBound(a,1) + 1)*(UBound(a,2) + 1)
a(0,0)是首指针,(UBound(a,1) + 1)*(UBound(a,2) + 1)计算清零的范围上面的应该没问题bad dll calling convention
没看过代码, 不敢乱说
谢谢 Hassle() !!
这个方法的速度应该比遍历数组每个元素然后赋值0 要快吧?
如果是就ok了!!