‘获取表字段列
Dim cnt As Integer = DataTables("表A").DataCols.Count - 1
Dim nms(cnt-1) As String
For i As Integer = 0 To cnt - 1
nms(i) = DataTables("表A").DataCols(i).name
Next
将nms(i)值在窗体中的组合选择框组件里显示出来
窗口插入一个CheckedListBox控件,一个“确定”按钮,一个“取消”按钮。
窗口的AfterLoad事件代码设置为:
Dim
lb As WinForm.CheckedListBox =
e.Form.Controls("CheckedListBox1")
lb.ComboList = nms(i)
“确定”按钮的代码设置为:
Dim s As
String
Dim l
As
WinForm.CheckedListBox =
e.Form.Controls("CheckedListBox1")
For
Each Index As
Integer
In l.CheckedIndices
If s > "" Then
s = s & ","
End
If
s = s & "'" & l.Items(Index) & "'"
Next
If s > "" Then
Tables("订单").Filter = "产品 In (" & s & ")"
End
If
e.Form.Close()
【老师,上述是先获取指定表中的所有列名称,然后赋值到复选框里,点击确定后,怎么实现所选择的第二列 第三列 第四列进行数据比对呢?
麻烦老师指导下 该楼的所有代码怎么有效融合使用呢?实现选定的指定列,进行数据比对,相同的就筛选为不显示,不相同就显示出来,并且能够导出为excel】
开始比对
Dim idx As String = "-1,"
Dim pdr As DataRow = Nothing
Dim cs As String = "客户,工序" 如何换成上述的S值
Dim flag As Boolean
For Each dr As DataRow In DataTables("表A").Select("客户 is not null and 工序 is not null", cs)
flag = False
If pdr IsNot Nothing Then
For Each c As String In cs.split(",")
If pdr(c) <> dr(c) Then
flag = True
Exit For
End If
Next
End If
If flag Then
idx &= pdr("_Identify") & ","
End If
pdr = dr
Next
If pdr IsNot Nothing Then
idx &= pdr("_Identify") & ","
End If
Tables("表A").filter = "_Identify in (" & idx.trim(",") & ") and 客户 is not null and 工序 is not null"
导出当前表数据为excel
Dim dlg As New
SaveFileDialog
'定义一个新的SaveFileDialog
dlg.Filter=
"excel文件|*.xls"
'设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim ex As New
Exporter
ex.SourceTableName = "表A"
'指定导出表
ex.filepath = dlg.FileName '指定目标文件
ex.Export() '开始导出
End If
[此贴子已经被作者于2021/10/21 20:55:25编辑过]