关于无组件上传程序中,自定义函数[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 。
此函数目的是在于在整个串中查找指定的字符串,并返回所在的字节位置,难道不减这个值不行吗?我真是不明白!
...全文
103 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
元明 2002-05-06
  • 打赏
  • 举报
回复
saucer(思归)
upfile_5xSoft_Stream.Size 请问这个值是字符串(提交的二进制流)的字节长度值吗?
Lostinet 2002-05-06
  • 打赏
  • 举报
回复
他那个东西是一个字节一个字节地解析的。。好慢。。。
广告:
http://lostinet.d2g.com/Temp/Public/Lostinet_Upload_1_03.zip
saucer 2002-05-06
  • 打赏
  • 举报
回复
你不必去求后面的东西,因为剩下的字符串(upfile_5xSoft_Stream.Size-theLen+1)已经不够输入的varStr长
julyclyde 2002-05-06
  • 打赏
  • 举报
回复
是的

如果从1开始数,数完这个请求数据就可以得到upfile_5xSoft_Stream.Size
但是现在是从theStart 开始数,如果数到upfile_5xSoft_Stream.Size就超出了。所以要减一下

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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