Foxtable(狐表)用户栏目专家坐堂 → foxtable 太诡异了,关于字符串问题。


  共有4185人关注过本帖树形打印复制链接

主题:foxtable 太诡异了,关于字符串问题。

帅哥哟,离线,有人找我吗?
well_nick
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:79 积分:1251 威望:0 精华:0 注册:2013/7/16 13:23:00
foxtable 太诡异了,关于字符串问题。  发帖心情 Post By:2013/8/31 15:24:00 [只看该作者]

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
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2013/8/31 15:27:00 [只看该作者]

这不很简单的嘛,长度不够了啊.长度没超过2360所以报错啊.

 回到顶部
帅哥哟,离线,有人找我吗?
Bin
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2013/8/31 15:28:00 [只看该作者]

你是没理解Substring 后面参数的意思吧 http://www.foxtable.com/help/topics/0240.htm

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

 回到顶部
帅哥哟,离线,有人找我吗?
well_nick
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:79 积分:1251 威望:0 精华:0 注册:2013/7/16 13:23:00
  发帖心情 Post By:2013/8/31 18:03:00 [只看该作者]

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


 回到顶部
帅哥哟,离线,有人找我吗?
nothing
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:517 积分:3383 威望:0 精华:0 注册:2013/1/3 17:08:00
  发帖心情 Post By: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也挺辛苦的

 回到顶部