Rss & SiteMap

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

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

标题:(请教)帮助修改1下代码

1楼
gdtgl 发表于:2008/12/1 22:04:00

正确的结果应是图1:


图片点击可在新窗口打开查看此主题相关图片如下:未命名.jpg
图片点击可在新窗口打开查看


文件:
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目4.table



错误的情况:

图片点击可在新窗口打开查看此主题相关图片如下:未命名3.jpg
图片点击可在新窗口打开查看
[此贴子已经被作者于2008-12-1 22:22:34编辑过]
2楼
gdtgl 发表于:2008/12/1 22:04:00
单独生成的代码:
'''
dim dackj as string
With tables("表A")
Dim ba As  Row = .current
for each biaoc as datarow in  datatables("表C").select("[编号] = '"& ba("编号") &"'")
   if biaoc("结果") = "检出"  then
       dackj =  dackj & "," & "编号" & biaoc("序号")   
       .current("结论") = dackj & "不合格"
    end if
next
End With
3楼
gdtgl 发表于:2008/12/1 22:08:00
全部生成的代码:(本来的思路是希望移动1行,就生成1行的结论,但没有想到:是移动,但会加上上一行的结论)

'''
dim dackj as string
With tables("表A")
for i as integer = 0 to .count
    .Position =  i
Dim ba As  Row = .current
for each biaoc as datarow in  datatables("表C").select("[编号] = '"& ba("编号") &"'")
   if biaoc("结果") = "检出"  then
       dackj =  dackj & "," & "编号" & biaoc("序号")     
       .current("结论") = dackj & "不合格"
    end if
next
next
End With
4楼
gdtgl 发表于:2008/12/1 22:17:00
请帮助修写,或重新写也行(能实现需要的结果就行了,又是试了好久不成功)
5楼
gdtgl 发表于:2008/12/1 23:36:00

图片点击可在新窗口打开查看终于找到1种可以实现的方法(用计算代码)



但想不通,(以下的代码也不行,晕中....)

'''
With tables("表A")
for i as integer = 0 to .count
    .Position =  i

dim dackj as string
with tables("表A.表C")
For r As integer = 0 To .Rows.Count - 1
   if  .rows(r)("结果") = "检出"  then
       dackj =  dackj & "," & "序号" & .rows(r)("序号")
      tables("表A").current("结论") = dackj & "不合格"
      end if
next
end with

next
End With




 

6楼
ybil 发表于:2008/12/2 0:35:00

'''
dim dr1,dr2 as datarow
dim bj,dackj as string
dim dt1,dt2 as datatable
dt1 = datatables("表A")
dt2 = datatables("表C")

for Each dr1 in dt1.select("[编号] >''")
    bj = "[编号] = '" & dr1("编号")
    bj = bj & "'And [结果] = '检出'"
    if dt2.Find(bj) Is Nothing  then
        dr1("结论") = "全部合格"  
    Else
        for each dr2 in Dt2.select(bj)
             dackj =  dackj & "," & "编号" & dr2("序号")        
        next
        dr1("结论") = dackj.substring(1) & "不合格"

    End If
next

7楼
gdtgl 发表于:2008/12/2 0:57:00
可能我说得不清楚,我要的是1楼图1的结果:

如20080001 我要的是1,38不合格
200800002  我要的是47不合格  (而不是要1,38,47不合格。这是2008001和20080002二个结果合并了)
200800003  我要的是53不合格  (而不是要1,38,47,53不合格,这是20080001、20080002、20080003三个结果的合并了)
8楼
don 发表于:2008/12/2 8:57:00

'''
dim dr1,dr2 as datarow
dim bj,dackj as string
dim dt1,dt2 as datatable
dt1 = datatables("表A")
dt2 = datatables("表C")

for Each dr1 in dt1.select("[编号] >''")
    bj = "[编号] = '" & dr1("编号")
    bj = bj & "'And [结果] = '检出'"
        dackj = ""
        for each dr2 in Dt2.select(bj)
             dackj =  dackj & "," & "编号" & dr2("序号")        
        next
        dr1("结论") = dackj.substring(1) & "不合格"
Next

9楼
gdtgl 发表于:2008/12/2 12:44:00
先顶1下,8楼符合要求.....


没有想到6楼知我想要的,写法应是这个:

'''
dim dr1,dr2 as datarow
dim bj,dackj as string
dim dt1,dt2 as datatable
dt1 = datatables("表A")
dt2 = datatables("表C")

for Each dr1 in dt1.select("[编号] >''")
    bj = "[编号] = '" & dr1("编号")
    bj = bj & "'And [结果] = '检出'"
             dackj = ""
        for each dr2 in Dt2.select(bj)
             dackj =  dackj & "," & "编号" & dr2("序号")        
        next
        if dackj <> "" then
            dr1("结论") = dackj.substring(1) & "不合格"
        else
            dr1("结论") = "全部合格"
       end if
Next

10楼
gdtgl 发表于:2008/12/2 12:45:00
流程加多了1个 dackj = ""  才能实现.....请问它的作用是?
共13 条记录, 每页显示 10 条, 页签: [1] [2]

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

Powered By Dvbbs Version 8.3.0
Processed in .02539 s, 3 queries.