Foxtable(狐表)用户栏目专家坐堂 → 提示startindex 不能大于字符串长度!


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

主题:提示startindex 不能大于字符串长度!

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


加好友 发短信
等级:幼狐 帖子:157 积分:2001 威望:0 精华:0 注册:2012/5/29 15:35:00
提示startindex 不能大于字符串长度!  发帖心情 Post By:2017/5/27 12:42:00 [只看该作者]

Dim lb2 As WinForm.Label = e.Form.Controls("Label2")
Dim lb3 As WinForm.Label = e.Form.Controls("Label3")
Dim p1 As WinForm.ProgressBar
p1 = e.Form.Controls("ProgressBar1")
p1.Maximum = DataTables("xjkh_lwg").DataRows.Count
p1.Minimum = 0 '设置最小值
p1.Value = 0 '设置当前值
lb2.Text = "正在分析数据……"
Dim Arys As List(Of String())
Arys = DataTables("dtgk_lwg").GetValues("使用车站|电梯编号|巡检点1|巡检点2") 
MainTable = Tables("xjkh_lwg")
systemready = False
For Each dr As DataRow In DataTables("xjkh_lwg").DataRows
    
    For Each Ary As String() In Arys
        If dr("使用车站") = ary(0) And (dr("placename") = ary(2) Or dr("placename") = ary(3))  Then 
            dr("dtcode") = ary(1)
            dr("xjsx") = ary(2) & "," & ary(3)
        End If
    Next
    p1.Value = p1.Value + 1
    lb2.Text = "正在分析数据……"
    'lb2.Text = lb2.text & "   " & p.Value & "/" & p.Maximum
    lb2.Text = lb2.text & "   " & Format(p1.value/p1.Maximum,"0%")

    application.Doevents
Next
lb2.Text = "分析数据完成!"
systemready = True
——————————————————

Dim p2 As WinForm.ProgressBar
p2 = e.Form.Controls("ProgressBar2")
p2.Maximum = jljls
p2.Minimum = 0 '设置最小值
p2.Value = 0 '设置当前值
lb3.Text = "正在生成巡检评价……"
'MainTable = Tables("xjkh_lwg")

systemready = False

For Each v() As String In DataTables("xjkh_lwg").GetValues("站段名称|使用车站|dtcode|linename|plandate")
    Dim dr1 As DataRow = DataTables("xjfx").AddNew()
    dr1("站段名称") = v(0)
    dr1("使用车站") = v(1)
    dr1("电梯编号") = v(2)
    dr1("计划名") = v(3)
    dr1("计划日期") = v(4)
    Dim rq As Date
    Date.TryParse(v(4),rq)
    Dim ztbz As Integer
    ztbz = 0
    'Dim pj As String
    Dim filter As String
    filter ="[站段名称] = '" & v(0) &  "'and [使用车站] = '" & v(1) & "' and  [dtcode] = '"  & v(2)  &  _
    " 'And [linename] = '" &  v(3) &  " ' And [plandate] = '" &  v(4) & "'"
    
    For Each dr2 As DataRow In DataTables("xjkh_lwg").Select(filter)
……………………代码
next
   p2.Value = p2.Value + 1
    lb3.Text = "正在生成巡检评价……"
    'lb3.Text = lb3.text & "   " & p2.Value & "/" & p2.Maximum
    lb3.Text = lb3.text & "   " & Format(p2.value/p2.Maximum,"0%")

    application.Doevents
Next
systemready = True
lb3.Text = "巡检评价写入完成!"
MainTable = Tables("xjfx")
Tables("xjfx").AutoSizeCols()

上述代码报startindex 不能大于字符串长度
横线上面部分代码运行正常,也能正常显示进度和百分比。横线下面部分,报startindex错误,我把红色部分去掉,能正常运行。

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


加好友 发短信
等级:超级版主 帖子:110592 积分:562856 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2017/5/27 14:52:00 [只看该作者]

p2.Value = p2.Value + 1

改为

if p2.value < jljls then p2.Value = p2.Value + 1

其它地方看不出问题

 回到顶部