Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共7 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:怎么增加一列数据列

1楼
lrh9537 发表于:2024/2/19 8:41:00
假如表A有一列“证件号码”(有18位数的,有20位数的),怎么通过代码在其后面增加一列“身份证号”(获取证件号码的前18位)
2楼
有点蓝 发表于:2024/2/19 9:07:00
http://www.foxtable.com/webhelp/topics/1452.htm

datacolchanged事件

If e.DataCol.Name = "证件号码" Then 
    If e.DataRow.IsNull("
证件号码") orelse len(e.DataRow("证件号码")) < 18 Then
        e.DataRow("身份证号") = Nothing
    
Else
        e.
DataRow("
身份证号") = left(e.DataRow("证件号码"),18) 'http://www.foxtable.com/webhelp/topics/3264.htm
    End
 If
End
 
If
3楼
lrh9537 发表于:2024/2/19 9:33:00
谢谢老师
某一列的内容发生变化后可以实现,比如我想通过按钮怎么来实现呢?
4楼
有点蓝 发表于:2024/2/19 9:51:00
遍历所有行处理:http://www.foxtable.com/webhelp/topics/1438.htm
5楼
lrh9537 发表于:2024/2/19 10:21:00
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))
6楼
有点蓝 发表于:2024/2/19 10:31:00
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编辑过]
7楼
lrh9537 发表于:2024/2/19 10:36:00
dr("证件号码").length >= 18

可以了,谢谢老师
共7 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .05469 s, 2 queries.