aByte()长度未知?那也许可以用on error 来处理边界 sub byte_copy(aByte(),bByte()) on error goto errhandle dim bStart as boolean dim i as long ,b as long bStart=false dim bByte() as byte redim bByte(1) while 1 if aByte(i)=&haa then bStart=true if aByte(i)=&h55 then bStart=false if bStart then bByte(b)=aByte(i) b=b+1 redim preseve bByte(b) end if i=i+1 wend errhandle: exit sub end sub
sub byte_copy(aByte(),bByte())
on error goto errhandle
dim bStart as boolean
dim i as long ,b as long
bStart=false
dim bByte() as byte
redim bByte(1)
while 1
if aByte(i)=&haa then bStart=true
if aByte(i)=&h55 then bStart=false
if bStart then
bByte(b)=aByte(i)
b=b+1
redim preseve bByte(b)
end if
i=i+1
wend
errhandle:
exit sub
end sub
instr
StrConv, vbFromUnicode ,vbUnicode
byte数组以及string之间互相赋值