Foxtable(狐表)用户栏目专家坐堂 → 未设置对象变量或 With 块变量


  共有1889人关注过本帖平板打印复制链接

主题:未设置对象变量或 With 块变量

帅哥哟,离线,有人找我吗?
刘林
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1942 积分:14925 威望:0 精华:0 注册:2016/4/28 9:58:00
未设置对象变量或 With 块变量  发帖心情 Post By:2016/11/12 22:09: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)
    Dim bmh As Integer
    Dim ksh As Integer
    Dim xm As Integer
    Dim sw As Integer
    Dim dl As Integer
    Dim njdm As Integer
    Dim bj As Integer
    Dim xxmc As Integer
    For i As Integer = 0 To sheet.Cols.count -1
        If sheet(0,i).value = "报名号"
            bmh =i
        End If
        If sheet(0,i).value = "考试号"
            ksh = i
        End If
        If sheet(0,i).value = "姓名"
            xm = i
        End If
        If sheet(0,i).value ="生物_A"
            sw = i
        End If
        If sheet(0,i).value ="地理_B"
            dl = i
        End If
        If sheet(0,i).value ="年级代码"
            njdm = i
        End If
        If sheet(0,i).value ="班级"
            bj = i
        End If
        If sheet(0,i).value = "单位名称"
            xxmc = i
        End If
    Next
    Tables("成绩").StopRedraw()
    For n As Integer = 1 To Sheet.Rows.Count -1
        Dim bmh1 As String = sheet(n,bmh).value.replace(" ","").replace(chr(9),"")
        Dim xm1 As String = sheet(n,xm).value.replace(" ","").replace(chr(9),"")
        Dim bj1 As String = sheet(n,bj).value.replace(" ","").replace(chr(9),"")
        Dim njdm1 As String = sheet(n,njdm).value.replace(" ","").replace(chr(9),"")
        Dim xxmc1 As String = sheet(n,xxmc).value.replace(" ","").replace(chr(9),"")
        Dim ksmc As String = e.Form.controls("combobox2").value
        '''' MessageBox.show(bmh1 & xm1 & bj1 & njdm1 & ksmc & xxmc1,"提示")
        Dim dr As DataRow = DataTables("成绩").sqlFind("单位名称 = '" & xxmc1 & "'and 姓名 = '" & xm1 & "'And 考试名称 = '" & ksmc & "' And 年级代码 = '" & njdm1 & "' And 班级 = '" & bj1 & "'")
        For m As Integer = 0 To sheet.Cols.count -1
            If dr Is Nothing Then 
                dr(sheet(0,m).value) = Sheet(n,m).Value

            Else
 Continue For
             End If
        Next  
    Next
    Tables("成绩").ResumeRedraw()
    
End If


请问老师上面代码是用EXCl 导入生物,地理成绩,注:如果找到符合条件的就把生物、地理成绩导入进行成绩表,否则不增加,再找下一个,出现:未设置对象变量或 With 块变量



 回到顶部