以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  foxtable 太诡异了,关于字符串问题。  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=39742)

--  作者:well_nick
--  发布时间:2013/8/31 15:24:00
--  foxtable 太诡异了,关于字符串问题。

Dim ss2 As String
 ss2 ="0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
Output.Show(len(ss2))
Output.Show(ss2.Substring(360,2000))

 

为什么Output.Show(ss2.Substring(350,2000)) 可以,Output.Show(ss2.Substring(360,2000))就报错?

System.ArgumentOutOfRangeException: 索引和长度必须引用该字符串内的位置。参数名: length 在 System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) 在 System.String.Substring(Int32 startIndex, Int32 length)

 


图片点击可在新窗口打开查看此主题相关图片如下:111.jpg
图片点击可在新窗口打开查看

--  作者:Bin
--  发布时间:2013/8/31 15:27:00
--  
这不很简单的嘛,长度不够了啊.长度没超过2360所以报错啊.
--  作者:Bin
--  发布时间:2013/8/31 15:28:00
--  
你是没理解Substring 后面参数的意思吧 http://www.foxtable.com/help/topics/0240.htm

第一个参数指的是从第几位开始截取,第二个参数指的是截取多少位.

--  作者:well_nick
--  发布时间:2013/8/31 18:03:00
--  

谢谢,知道了,谢谢各位帮助


--  作者:nothing
--  发布时间:2013/8/31 21:53:00
--  
可以
Dim ss2 As New String("0", 2360)
Output.Show(len(ss2))
Output.Show(ss2.Substring(360,2000))

打2000多个0也挺辛苦的