Rss & SiteMap

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

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

标题:[求助]自动编号前加前缀求教!

1楼
taigor 发表于:2011/12/28 15:59:00
请教工程师,您看下下面代码,生成的编号格式为:20111228-001
我需要在这个编号前加前缀,比如生成 YP20111228-001,编号统一以“YP”开头,请教代码该怎么写?
多谢多谢!!!!!

If e.DataCol.Name = "日期" Then
    If e.DataRow.IsNull("日期") Then
        e.DataRow("编号") = Nothing
    Else
        Dim bh As String = Format(e.DataRow("日期"),"yyyyMMdd") 
        If e.DataRow("编号").StartsWith(bh) = False 
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(编号)","日期 = #" & e.DataRow("日期") & "#") 
            If max > "" Then '如果存在最大编号
                idx = CInt(max.Substring(9,3)) + 1 
            Else
                idx = 1 
            End If
            e.DataRow("编号") = bh & "-" & Format(idx,"000")
        End If
    End If
End If
2楼
狐狸爸爸 发表于:2011/12/28 16:01:00
If e.DataCol.Name = "日期" Then
    If e.DataRow.IsNull("日期") Then
        e.DataRow("编号") = Nothing
    Else
        Dim bh As String = "YP" & Format(e.DataRow("日期"),"yyyyMMdd")
        If e.DataRow("编号").StartsWith(bh) = False
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(编号)","日期 = #" & e.DataRow("日期") & "#")
            If max > "" Then '如果存在最大编号
                idx = CInt(max.Substring(11,3)) + 1
            Else
                idx = 1
            End If
            e.DataRow("编号") = bh & "-" & Format(idx,"000")
        End If
    End If
End If
3楼
taigor 发表于:2011/12/28 16:04:00
多谢多谢!!真够效率!!
共3 条记录, 每页显示 10 条, 页签: [1]

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

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