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
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
暂无评论...
更新日志
2024年11月22日
2024年11月22日
- 张梦弘《大城小爱HQ》头版限量编号[低速原抓WAV+CUE]
- 张敬轩《MY 1ST COLLECTION》2CD[WAV+CUE][1.7G]
- 张玮伽《夜归人HQⅡ》2024头版限量编号[WAV+CUE][523M]
- 证声音乐图书馆《夏至 爵士境地》[320K/MP3][70.37MB]
- 孙露《同名专辑》限量1:1母盘直刻[低速原抓WAV+CUE]
- 【宝丽金唱片】群星《鼓舞飞扬》WAV+CUE
- 莫扎特弗雷德沃夏克肖斯塔科维奇《钢琴五重奏》(DG24-96)FLAC
- 证声音乐图书馆《夏至 爵士境地》[FLAC/分轨][360.16MB]
- 证声音乐图书馆《日落琴声 x 弦乐》[320K/MP3][71.2MB]
- 证声音乐图书馆《日落琴声 x 弦乐》[FLAC/分轨][342.58MB]
- 谢采妘2011《难忘的旋律(Non-StopChaCha)》马来西亚版[WAV+CUE]
- 林翠萍《听见林翠萍,记忆就会醒来》2CD[WAV+CUE]
- 木村好夫《天龍HIFI木吉他、木村好夫精选好歌》日本天龙版[WAV整轨]
- 证声音乐图书馆《日出琴声 x 民谣》[320K/MP3][53.76MB]
- 证声音乐图书馆《日出琴声 x 民谣》[FLAC/分轨][239.29MB]