以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]代码遍历问题? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=82321) |
-- 作者:zgjmost -- 发布时间:2016/3/15 20:08:00 -- [求助]代码遍历问题? 下面这段代码怎么执行不了? Forms("主界面").Open() MainTable = Tables("主界面") Dim dlg As new OpenFileDialog If dlg.ShowDialog = DialogResult.OK Then Dim fl As String = dlg.FileName Dim book As new XLS.Book Dim Sheet As XLS.Sheet = Book.Sheets(0) For i As Integer = 1 To sheet.Rows.Count -1 If sheet(i,22).value = "本科" AndAlso sheet(i,26).value = "中央广播电视大学" AndAlso sheet(i,30).value = "自考" Then Dim r As Row = Tables("校对信息").AddNew r("姓名") = sheet(i,3).value r("身份证号") = sheet(i,7).value r("教学点名称") = sheet(i,1).value r("创建人") = sheet(i,39).value r("错误原因") = "中央广播电视大学的学习形式不可能是自考" ElseIf sheet(i,22).value = "本科" AndAlso sheet(i,32).text.SubString(1,5) = "51161" AndAlso sheet(i,30).value = "自考" Then Dim r As Row = Tables("校对信息").AddNew r("姓名") = sheet(i,3).value r("身份证号") = sheet(i,7).value r("教学点名称") = sheet(i,1).value r("创建人") = sheet(i,39).value r("错误原因") = "51161的学习形式不可能是自考" ElseIf sheet(i,22).value = "本科" AndAlso sheet(i,26).value = "国家开放大学" AndAlso sheet(i,30).value = "自考" Then Dim r As Row = Tables("校对信息").AddNew r("姓名") = sheet(i,3).value r("身份证号") = sheet(i,7).value r("教学点名称") = sheet(i,1).value r("创建人") = sheet(i,39).value r("错误原因") = "国家开放大学的学习形式不可能是自考" ElseIf sheet(i,22).value = "本科" AndAlso sheet(i,32).text.SubString(1,6) = "511615" AndAlso sheet(i,30).value <> "中央广播电视大学" Then Dim r As Row = Tables("校对信息").AddNew r("姓名") = sheet(i,3).value r("身份证号") = sheet(i,7).value r("教学点名称") = sheet(i,1).value r("创建人") = sheet(i,39).value r("错误原因") = "511615的学校名称不正确,应是中央广播电视大学" ElseIf sheet(i,22).value = "本科" AndAlso sheet(i,32).text.SubString(1,6) = "511618" AndAlso sheet(i,30).value <> "国家开放大学" Then Dim r As Row = Tables("校对信息").AddNew r("姓名") = sheet(i,3).value r("身份证号") = sheet(i,7).value r("教学点名称") = sheet(i,1).value r("创建人") = sheet(i,39).value r("错误原因") = "511618的学校名称不正确,应是国家开放大学" ElseIf sheet(i,22).value = "本科" AndAlso sheet(i,32).text.SubString(1,5) = "51305" AndAlso sheet(i,30).value <> "湖北广播电视大学" Then Dim r As Row = Tables("校对信息").AddNew r("姓名") = sheet(i,3).value r("身份证号") = sheet(i,7).value r("教学点名称") = sheet(i,1).value r("创建人") = sheet(i,39).value r("错误原因") = "51305的学校名称不正确,应是湖北广播电视大学" ElseIf sheet(i,22).value = "本科" AndAlso sheet(i,32).text.SubString(1,5) = "51305" AndAlso sheet(i,30).value = "自考" Then Dim r As Row = Tables("校对信息").AddNew r("姓名") = sheet(i,3).value r("身份证号") = sheet(i,7).value r("教学点名称") = sheet(i,1).value r("创建人") = sheet(i,39).value r("错误原因") = "湖北广播电视大学的学习形式不可能是自考" ElseIf sheet(i,22).value = "本科" AndAlso sheet(i,32).text.SubString(1,8) <> "51161520" AndAlso sheet(i,30).value = "中央广播电视大学" Then Dim r As Row = Tables("校对信息").AddNew r("姓名") = sheet(i,3).value r("身份证号") = sheet(i,7).value r("教学点名称") = sheet(i,1).value r("创建人") = sheet(i,39).value r("错误原因") = "学校名称不正确,应是中央广播电视大学" ElseIf sheet(i,22).value = "本科" AndAlso sheet(i,32).text.SubString(11,2) = "05" AndAlso sheet(i,30).value = "自考" AndAlso sheet(i,32).text.SubString(17,2) = "" Then Dim r As Row = Tables("校对信息").AddNew r("姓名") = sheet(i,3).value r("身份证号") = sheet(i,7).value r("教学点名称") = sheet(i,1).value r("创建人") = sheet(i,39).value r("错误原因") = "该学员的学习形式不可能是自考" ElseIf sheet(i,22).value = "本科" AndAlso sheet(i,32).text.SubString(11,2) = "06" AndAlso sheet(i,30).value = "自考" AndAlso sheet(i,32).text.SubString(17,2) = "" Then Dim r As Row = Tables("校对信息").AddNew r("姓名") = sheet(i,3).value r("身份证号") = sheet(i,7).value r("教学点名称") = sheet(i,1).value r("创建人") = sheet(i,39).value r("错误原因") = "该学员的学习形式不可能是自考" ElseIf sheet(i,22).value = "本科" AndAlso sheet(i,32).text.SubString(11,2) = "06" AndAlso sheet(i,30).value = "非自考" AndAlso sheet(i,25).value = "本科" AndAlso sheet(i,32).text.SubString(17,2) = "" Then Dim r As Row = Tables("校对信息").AddNew r("姓名") = sheet(i,3).value r("身份证号") = sheet(i,7).value r("教学点名称") = sheet(i,1).value r("创建人") = sheet(i,39).value r("错误原因") = "该学员的学习形式学习形式错误" ElseIf sheet(i,22).value = "本科" AndAlso sheet(i,32).text.SubString(11,2) = "05" AndAlso sheet(i,30).value = "非自考" AndAlso sheet(i,25).value = "专科" AndAlso sheet(i,32).text.SubString(17,2) = "" Then Dim r As Row = Tables("校对信息").AddNew r("姓名") = sheet(i,3).value r("身份证号") = sheet(i,7).value r("教学点名称") = sheet(i,1).value r("创建人") = sheet(i,39).value r("错误原因") = "该学员的学习形式学习形式错误" Else MainTable = Tables("主界面") End If Next End If |
-- 作者:大红袍 -- 发布时间:2016/3/15 20:40:00 -- Dim fl As String = dlg.FileName Dim book As new XLS.Book
改成
Dim fl As String = dlg.FileName
Dim book As new XLS.Book(fl) |