以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  代码请教  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=103791)

--  作者:cuicuibing
--  发布时间:2017/7/17 10:11:00
--  代码请教
想做一个图纸打印次数的控制。
第一个实现:
       打印总控制表:
                           代码     人名      打印次数
                           001      aaa         2
                           002      bbb        3
                           003      ccc          1
如何实现将以上   代码+次数   合并为如下格式
                       001|2,002|3,003|1

第二个实现: 根据代码 查找  次数

                比如   从(001|2,002|3,003|1)中查找003的次数
第三个实现:    把002的打印次数减少1,并更改记录
                    001|2,002|3,003|1  变更为  001|2,002|2,003|1


                             

--  作者:有点甜
--  发布时间:2017/7/17 11:10:00
--  

1、

 

Dim t As Table = Tables("表A")
Dim str As String = ""
For Each r As Row In t.rows
    str &= r("第一列") & "|" & r("第二列") & ","
Next
str = str.trim(",")
msgbox(str)


--  作者:有点甜
--  发布时间:2017/7/17 11:12:00
--  

2、

 

Dim str As String = "001|2,002|3,003|1"
Dim s As String = "003"

For Each ss As String In str.Split(",")
    Dim ary() As String = ss.Split("|")
    If ary(0) = s Then
        msgbox(ary(1))
    End If
Next


--  作者:有点甜
--  发布时间:2017/7/17 11:14:00
--  

3、

 

Dim str As String = "001|2,002|3,003|1"
Dim s As String = "003"
Dim nstr As String = ""
For Each ss As String In str.Split(",")
    Dim ary() As String = ss.Split("|")
    If ary(0) = s Then
        ary(1) -= 1
    End If
    nstr &= ary(0) & "|" & ary(1) & ","
Next
nstr = nstr.trim(",")
msgbox(nstr)