以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]find中变量使用代码  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=86294)

--  作者:方丈
--  发布时间:2016/6/15 8:08:00
--  [求助]find中变量使用代码

请教,下面的代码,不知道哪里错了?

 

 

Dim t1 As Table
t1 = e.form.Controls("Table2").Table
Dim F As String = t1.name
Dim dlg As New OpenFileDialog
dlg.MultiSelect = True
dlg.Filter= "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog = DialogResult.OK Then
    For Each km As String In DataTables(F).GetValues("接收数据列名","是否导入 = \'True\'")
        For Each fl As String In dlg.FileNames
            Dim Book As New xls.Book(fl)
            Dim Sheet As XLS.Sheet = Book.Sheets(0)
            Dim nms As new Dictionary (of String,Integer)
           
            For i As Integer = 0 To Sheet.Cols.Count -1
                If Sheet(0,i).Value <> "" Then
                    nms.add(Sheet(0,i).Value.Trim(),i)
                   
                End If
            Next
           
            For n As Integer = 1 To Sheet.Rows.Count -1
                Dim M As String = e.Form.Controls("TextBox1").text
                Dim P As String = e.Form.Controls("TextBox2").text             

                Dim D As String = CurrentTable.name
               
                Dim sfz As String = sheet(n,nms(M)).Text  \'获取身份证号
                Dim dr As DataRow = DataTables(D).Find("P = \'" & sfz & "\'")
                If dr IsNot Nothing
                    dr( km ) = sheet(n,nms(km)).text
                End If
            Next
        Next
                
    Next
End If

[此贴子已经被作者于2016/6/15 8:08:42编辑过]

--  作者:Hyphen
--  发布时间:2016/6/15 8:33:00
--  
Dim dr As DataRow = DataTables(D).Find(P & " = \'" & sfz & "\'")