以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  未将对象引用设置到对象的实例  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=91509)

--  作者:刘林
--  发布时间:2016/10/12 14:04:00
--  未将对象引用设置到对象的实例
 老师,下面代码出现:未将对象引用设置到对象的实例,请问什么原因,怎么办,谢谢

Dim dlg As new OpenFileDialog
dlg.Filter = "Excel|*.xls;*.xlsx"
If dlg.ShowDialog = DialogResult.OK Then
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    Tables("上分_table1").StopRedraw()
    Dim mc As String = sheet(0,1).value
    Dim dm As String = sheet(1,1).value
    Dim bj As String = sheet(2,1).value
    Dim ksmc As String = sheet(3,1).value
    Dim kmA As String = sheet(4,1).value & "_A"
    Dim kmB As String = sheet(4,1).value & "_B"

    For n As Integer = 5 To Sheet.Rows.Count -1
        Dim kh As String = sheet(n+1,0).value
        Dim dr As DataRow = DataTables("成绩").Find("班级 = \'" & bj & "\'and 单位名称 = \'" & mc & "\' and 年级代码 = \'" & dm & "\'and 考试名称 = \'" & ksmc & "\' and 考号= \'" & kh & "\'")
        dr(kmA) = sheet(n+1,2).value
        dr(kmB) = sheet(n+1,3).value
    Next
Tables("上分_table1").ResumeRedraw()
End If

--  作者:有点蓝
--  发布时间:2016/10/12 14:57:00
--  
http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=91463&page=1&star=2

请不要重复发贴