以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]求遍历字符组的计数如何做,分数,几分之几 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=162183) |
||||
-- 作者:myjht -- 发布时间:2021/4/8 10:59:00 -- [求助]求遍历字符组的计数如何做,分数,几分之几 求如下图,规格列“3左+3右”,按“+”拆分后计数,和当前打印第几个的语句如何写, Dim doc As New PrintDoc \'定义一个报表 \'添加打印内容 Dim img As prt.RenderImage \'定义一个图片对象 Dim Bar As New BarCodeBuilder Bar.Symbology = Barpro.Symbology.Code39 \'Bar.Rotate = Barpro.Rotate.Degree90 \'旋转条码 For Each r2 As Row In Tables("zzscjjzb").Rows Dim nms() As String = r2("规格").Split("+") \'将规格列内容拆分成数组 For k As Integer = 1 To r2("数量") \'加一个循环 For Each nm As String In nms \'遍历参与加工此产品的每个工号 \'下面很简单,指定每一个单元格的内容 rt.Cells(0,0).Text= "工单号" rt.Cells(0,1).Text = r2("工单号") rt.Cells(4,0).Text= "产品名称" rt.Cells(4,1).Text = r2("产品名称") rt.Cells(5,0).Text= "颜色" rt.Cells(5,1).Text = r2("颜色") rt.Cells(6,0).Text= "件数" rt.Cells(6,1).Text = r2("件数") rt.Cells(7,0).Text= "数量" rt.Cells(7,1).Text = r2("数量") If r2("规格") = "" Then rt.Cells(8,0).Text= "套规格" rt.Cells(8,1).Text = nm Else rt.Cells(8,0).Text= "套规格" rt.Cells(8,1).Text = r2("规格") & " / " & nm End If rt.Cells(9,0).Text= "单据备注" rt.Cells(9,1).Text = r2("单据备注") rt.Cells(10,0).Text = r2("非标说明") bar.Code = r2("_Identify") img = new prt.RenderImage img.Image = bar.GetImage img.Height = 13 \'"Auto" \'高度由图片大小自动决定 ra.Children.Add(rt) \'加入到容器中 ra.Children.Add(img) \'加入图片到RenderArea中 Doc.Body.ChildRen.Add(ra) \'将容器加入到报表中 Next Next Next Doc.Preview() \'预览报表 |
||||
-- 作者:myjht -- 发布时间:2021/4/8 11:18:00 -- 代码
|
||||
-- 作者:有点蓝 -- 发布时间:2021/4/8 11:20:00 -- 这个意思? For i as integer = 0 to nms.length - 1 msgbox((i+1) & "/" & nms.length) next
|
||||
-- 作者:myjht -- 发布时间:2021/4/8 14:56:00 -- [求助]求遍历字符组的计数如何做,分数,几分之几 感谢篮版,不过我加到那个位置合适?我的循环冲突了 Dim doc As New PrintDoc \'定义一个报表 For Each r2 As Row In Tables("zzscjjzb").Rows Dim nms() As String = r2("规格").Split("+") \'将规格列内容拆分成数组 For k As Integer = 1 To r2("数量") \'加一个循环 For i As Integer = 0 To nms.length - 1 For Each nm As String In nms \'遍历参与加工此产品的每个工号 rt.Cells(4,1).Text = r2("产品名称") rt.Cells(5,0).Text= "颜色" rt.Cells(5,1).Text = r2("颜色") rt.Cells(6,0).Text= "件数" rt.Cells(6,1).Text = r2("件数") rt.Cells(7,0).Text= "数量" rt.Cells(7,1).Text = r2("数量") If r2("规格") = "" Then rt.Cells(8,0).Text= "套规格" rt.Cells(8,1).Text = nm Else rt.Cells(8,0).Text= "套规格" \'rt.Cells(8,1).Text = r2("规格") & " / " & nm rt.Cells(8,1).Text = r2("规格") & " / " & nm & (i+1) & "/" & nms.length End If ra.Children.Add(rt) \'加入到容器中 ra.Children.Add(img) \'加入图片到RenderArea中 Doc.Body.ChildRen.Add(ra) \'将容器加入到报表中 Next Next Next Next Doc.Preview() \'预览报表 |
||||
-- 作者:有点蓝 -- 发布时间:2021/4/8 15:22:00 -- For k As Integer = 1 To r2("数量") \'加一个循环 For i As Integer = 0 To nms.length - 1 \'删除这行For Each nm As String In nms \'遍历参与加工此产品的每个工号 dim nm as string = nms(i) rt.Cells(4,1).Text = r2("产品名称") rt.Cells(5,0).Text= "颜色" rt.Cells(5,1).Text = r2("颜色") |
||||
-- 作者:myjht -- 发布时间:2021/4/8 16:50:00 -- 感谢篮版, 新手小白,憋了好几天,最后一个问题,如果r2(“产品名称”)包含“外阜”这个文字,条码打印4份,否则打印1份, 对应的rt.Cells(8,1).Text = r2("规格") & " / " & nm & (i+1) & "/" & nms.length,也要同步,这个应该怎么写。
|
||||
-- 作者:有点蓝 -- 发布时间:2021/4/8 17:01:00 -- 没看懂,意思是总共要打印4 X nms.length 这么多份? |
||||
-- 作者:myjht -- 发布时间:2021/4/9 9:37:00 -- [求助]求遍历字符组的计数如何做,分数,几分之几 蓝版,是的,打印4份条码。 代码如下:
|
||||
-- 作者:有点蓝 -- 发布时间:2021/4/9 9:57:00 -- For Each r2 As Row In Tables("zzscjjzb").Rows Dim nms() As String = r2("规格").Split("+") \'将规格列内容拆分成数组 For k As Integer = 1 To r2("数量") \'加一个循环 dim k as integer = 0 if r2(“产品名称”)like“*外阜*”then k = 3 dim g as integer = nms.length if k>0 then g = g * (k+1) dim idx as integer = 1 for m as integer = 0 to k For i As Integer = 0 To nms.length - 1 Dim nm As String = nms(i) Dim rt As New prt.RenderTable() \'定义一个表格对象 Dim rx As New prt.RenderText \'定义一个文本对象 …… If r2("规格") = "" Then rt.Cells(8,0).Text= "套规格" rt.Cells(8,1).Text = nm Else rt.Cells(8,0).Text= "套规格" rt.Cells(8,1).Text = r2("规格") & " / " & nm & idx & "/" & g idx += 1 End If
|
||||
-- 作者:myjht -- 发布时间:2021/4/10 16:48:00 -- [求助]求遍历字符组的计数如何做,分数,几分之几 篮版,谢谢您,终于搞出来了,就是300张条码以上容易死机 应该是代码循环的太多了吧?这判断也只能这样子了,不知如何优化
|