老师,
标注颜色的部分 会提示错误 ,应该怎么改呢?
.NET Framework 版本:2.0.50727.8830
Foxtable 版本:2018.3.9.1
错误所在事件:自定义函数za_nb_rederegular
详细错误信息:
调用的目标发生了异常。
索引和长度必须引用该字符串内的位置。
参数名: length
Dim e As object=args(0)
'判断编码规则开始
Dim dt As DataTable=Functions.Execute("tablloading","readrules")
If dt.DataRows.count>0 Then
Dim name As String
Dim dr As DataRow=dt.find("[tblcolid]='"& e.DataCol.Name &"' and [tbltname]='"& e.DataTable.name &"'")
If dr IsNot Nothing Then
'读取规则
Dim reg As new System.Text.RegularExpressions.Regex(dr("colrgular"))
If reg.Ismatch(e.NewValue) = False Then
e.Cancel = True
PopMessage("不符合规则")
Return Nothing
Else
Dim count As Integer = 0
For i As Integer = 0 To dr("colong").length - 1
count += val(dr("colong").chars(i))
Dim str As String = e.NewValue.Substring(0, count)
MessageBox.Show(count < e.NewValue.length)
If count < e.NewValue.length Then
If e.DataTable.find(dr("tblcolid") & "='" & str & "'") Is Nothing Then
MessageBox.Show(2)
PopMessage("缺少上级编码:" & str,"错误", PopIconEnum.Error, 5)
e.Cancel = True
Return Nothing
Exit For
MessageBox.Show(3)
End If
End If
Next
End If
End If
End If
[此贴子已经被作者于2018/6/5 14:12:37编辑过]