清风细雨楼 Design By www.eepep.com
dim函数的第三个参数,也就是截取字符的长度,我在设置这个的时候,出了些问题:response.write mid(up_address,a(i),a(i+1)-1) & “<br />”像我上面这样写的时候,它就会报错,提示无效的过程调用或参数,
response.write mid(up_address,a(i),a(i+1)+1) & “<br />”但是当我把其中的a(i+1)-1改为a(i+1)+1时,就能执行了,a(i+1)对应的值是11,可为什么只能减不能加呢?全部代码如下:
VB code:
复制代码 代码如下:
dim a(),up_address
up_address = "aaa djaldk adflj adafadfasdfa afd ad"
redim a(len(up_address))
a(0) = instr(up_address," ")
response.write a(0) & "<br />"
if a(0)<>0 then
for i=0 to len(up_address)-1
a(i+1) = instr(a(i)+1,up_address," ")
response.write mid(up_address,a(i),a(i+1)-1) & "<br />"
if a(i+1)=0 then
exit for
end if
response.write a(i+1) & "<br />"
next
end if如上代码,我是想把字符串按空格分解出来,但是mid的第三个参数那出了点问题,我本来是想这样截取的:
VB code:
复制代码 代码如下:
mid(up_address,a(i),a(i+1)-a(i)-1)
‘a(i)是空格的位置
‘a(i+1)是下一个空格的位置
‘a(i+1)-a(i)-1是两个空格直间的字符长度
现在的问题是,经测试,mid的第三个参数那,无法使用减法,也就是说,我可以写a(i+1)+,但不能写a(i+1)-,想了好久,我一直不明白问题出在哪?应该怎么来解决呢?
出现这个问题是因为上面的MID函数的第三个参数出现了负数,下面是在网上找的测试的VBS代码,原理一样,如下的代码:
VBScript code:
复制代码 代码如下:
dim a(),up_address
up_address = "aaa djaldk adflj adafadfasdfa afd ad"
MsgBox len(up_address) '36
redim a(len(up_address)) 'a(36)
a(0) = instr(up_address," ")
MsgBox a(0) 'a(0)=4
MsgBox a(0) & "<br />"
if a(0)<>0 then
for i=0 to len(up_address)-1
a(i+1) = instr(a(i)+1,up_address," ")
MsgBox a(i) &" "& (a(i+1)-1)‘这里的结果为34,-1,所以导致出错
MsgBox mid(up_address,a(i),a(i+1)-1) & "<br />"
if a(i+1)=0 then
exit for
end if
MsgBox a(i+1) & "<br />"
next
end if
response.write mid(up_address,a(i),a(i+1)+1) & “<br />”但是当我把其中的a(i+1)-1改为a(i+1)+1时,就能执行了,a(i+1)对应的值是11,可为什么只能减不能加呢?全部代码如下:
VB code:
复制代码 代码如下:
dim a(),up_address
up_address = "aaa djaldk adflj adafadfasdfa afd ad"
redim a(len(up_address))
a(0) = instr(up_address," ")
response.write a(0) & "<br />"
if a(0)<>0 then
for i=0 to len(up_address)-1
a(i+1) = instr(a(i)+1,up_address," ")
response.write mid(up_address,a(i),a(i+1)-1) & "<br />"
if a(i+1)=0 then
exit for
end if
response.write a(i+1) & "<br />"
next
end if如上代码,我是想把字符串按空格分解出来,但是mid的第三个参数那出了点问题,我本来是想这样截取的:
VB code:
复制代码 代码如下:
mid(up_address,a(i),a(i+1)-a(i)-1)
‘a(i)是空格的位置
‘a(i+1)是下一个空格的位置
‘a(i+1)-a(i)-1是两个空格直间的字符长度
现在的问题是,经测试,mid的第三个参数那,无法使用减法,也就是说,我可以写a(i+1)+,但不能写a(i+1)-,想了好久,我一直不明白问题出在哪?应该怎么来解决呢?
出现这个问题是因为上面的MID函数的第三个参数出现了负数,下面是在网上找的测试的VBS代码,原理一样,如下的代码:
VBScript code:
复制代码 代码如下:
dim a(),up_address
up_address = "aaa djaldk adflj adafadfasdfa afd ad"
MsgBox len(up_address) '36
redim a(len(up_address)) 'a(36)
a(0) = instr(up_address," ")
MsgBox a(0) 'a(0)=4
MsgBox a(0) & "<br />"
if a(0)<>0 then
for i=0 to len(up_address)-1
a(i+1) = instr(a(i)+1,up_address," ")
MsgBox a(i) &" "& (a(i+1)-1)‘这里的结果为34,-1,所以导致出错
MsgBox mid(up_address,a(i),a(i+1)-1) & "<br />"
if a(i+1)=0 then
exit for
end if
MsgBox a(i+1) & "<br />"
next
end if
清风细雨楼 Design By www.eepep.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
清风细雨楼 Design By www.eepep.com
暂无评论...
更新日志
2024年12月27日
2024年12月27日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]