关于无组件上传程序中,自定义函数[instring()]的疑问?关键字:化境 string stream
元明 2002-05-06 10:19:43 Private Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to upfile_5xSoft_Stream.Size-theLen
if i>upfile_5xSoft_Stream.size then exit Function
upfile_5xSoft_Stream.Position=i-1
if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if upfile_5xSoft_Stream.EOS then
inString=0
Exit for
end if
if AscB(upfile_5xSoft_Stream.Read(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function
在语句的第6行:for i=theStart to upfile_5xSoft_Stream.Size-theLen
最后为什么要减 theLen 。
此函数目的是在于在整个串中查找指定的字符串,并返回所在的字节位置,难道不减这个值不行吗?我真是不明白!