假如表A有一列“证件号码”(有18位数的,有20位数的),怎么通过代码在其后面增加一列“身份证号”(获取证件号码的前18位)
datacolchanged事件
If e.DataCol.Name = "证件号码" Then
If e.DataRow.IsNull("证件号码") orelse len(e.DataRow("证件号码")) < 18 Then
谢谢老师
某一列的内容发生变化后可以实现,比如我想通过按钮怎么来实现呢?
Dim w As DataRow
For Each dr As DataRow In DataTables("表A").DataRows
w = DataTables("表A").Find("证件号码 = '" & dr("证件号码") & "'")
If w IsNot Nothing Then
dr("身份证号") = w("证件号码")
End If
Next
DataTables("表A").Save
可以实现全部导过来,想提取前18位怎么修改代码(left(e.DataRow("证件号码"),18))
For Each dr As DataRow In DataTables("表A").DataRows
if dr.isnull("证件号码") =false andalso dr("证件号码").length > 18
dr("身份证号") = left(dr("证件号码"),18)
end if
Next
DataTables("表A").Save
[此贴子已经被作者于2024/2/19 10:31:02编辑过]