以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  提示startindex 不能大于字符串长度!  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=101263)

--  作者:xxcwdlwgo
--  发布时间:2017/5/27 12:42:00
--  提示startindex 不能大于字符串长度!
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错误,我把红色部分去掉,能正常运行。

--  作者:有点蓝
--  发布时间:2017/5/27 14:52:00
--  
p2.Value = p2.Value + 1

改为

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

其它地方看不出问题