以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 导入数据时出现问题:索引和长度必须引用该字符串内的位置 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=134703) |
-- 作者:sunion -- 发布时间:2019/5/4 20:36:00 -- 导入数据时出现问题:索引和长度必须引用该字符串内的位置 按钮导入时出现问题,不知道什么原因: 索引和长度必须引用该字符串内的位置。 参数名: length 原始代码: Dim dlg As New OpenFileDialog dlg.Filter = "Excel文件|*.xls" dlg.MultiSelect = True \'允许选择多个文件 If dlg.ShowDialog =DialogResult.OK Then Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets(0) Tables("学生信息表").StopRedraw() \'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致 Dim nms() As String = {"国籍号","学号","班级","班级编号","姓名","性别","出生年月","民族","政治面貌","籍贯","身份证号","户口所在地","毕业学校","兴趣爱好","所获荣誉","家庭住址"} For n As Integer = 2 To Sheet.Rows.Count -1 Dim bh As String = sheet(n,1).Text If DataTables("学生信息表").Find("学号 = \'" & bh & "\' and 学校 = \'" & e.form.Controls("xxmc").text & "\' ") Is Nothing Then \'如果不存在同编号的订单 Dim r As Row = Tables("学生信息表").AddNew() \'Dim r As Row = Tables("班主任主页_Table1").AddNew() For m As Integer = 0 To nms.Length - 1 r(nms(m)) = Sheet(n,m).Value Next \'Else \' MessageBox.Show("该学生已存在!请检查数据!") End If Next Tables("学生信息表").ResumeRedraw() End If For Each dr As DataRow In DataTables("学生信息表").DataRows If dr("学号") IsNot Nothing Then dr("班级编号") = dr("学号").SubString(0,6) dr("入学年份") = dr("学号").SubString(0,4) dr("学校") = "" & e.Form.Controls("xxmc").text & "" End If Next Tables("学生信息表").save [此贴子已经被作者于2019/5/4 20:36:41编辑过]
|
-- 作者:有点甜 -- 发布时间:2019/5/5 9:51:00 -- If dr("学号") IsNot Nothing Then
改成
If dr("学号").length > 6 Then |