以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  麻烦老师帮忙看看 为什么第二个遍历循环 启用之后 会一直循环完毕了都不弹出提示已经完成的内容和打开指定目录呢  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=170337)

--  作者:cnsjroom
--  发布时间:2021/7/22 12:43:00
--  麻烦老师帮忙看看 为什么第二个遍历循环 启用之后 会一直循环完毕了都不弹出提示已经完成的内容和打开指定目录呢
麻烦老师帮忙看看  为什么第二个遍历循环 启用之后 会一直循环完毕了都不弹出提示已经完成的内容和打开指定目录呢

如果把红色部分代码取消  又会正确弹出提示和打开指定目录

Dim abc As String
Dim fl As String
Dim f2 As String
Dim i As Integer
Dim Products As List(Of String)
Products = DataTables("数据表").SQLGetValues("d5","","d5")
If Products.Count > 1 Then
    For i = 0 To Products.Count - 1
        Dim Products1 As List(Of String)
        For Each Product As String In Products
            Products1 = DataTables("数据表").SQLGetValues("d7","d5=\'" & Product & "\'","d7")
            Dim s1 As String = Products1(0)
            If Products1.Count > 1 Then
                s1 = s1 & "至" & Products1(Products1.Count - 1)
            End If
            Dim sum As Double = DataTables("数据表").SQLCompute("sum(d8)","d5=\'" & Product & "\'")
            Dim Book As New XLS.Book(ProjectPath & "Attachments\\物业费模板.xls")
            Dim Sheet As XLS.Sheet = Book.Sheets(0)
            Sheet(2,9).Value = "<d5 = \'" & Product  & "\'>"  \'写入打印条件
            If Product.Contains("/") Then
                output.show(Product)
                abc  = Product.Replace("/","-")
                fl  = ProjectPath & "Reports\\" & abc & "【" & s1 & "欠款" & sum & "元】.xls"
            Else
                fl  = ProjectPath & "Reports\\" & Product & "【" & s1 & "欠款" & sum & "元】.xls"
            End If
            Book.Build()
            Book.Save(fl)
        Next
    Next
    MessageBox.Show("单个表已经生成!","温馨提示")
    Dim Proc As New Process
    Dim dk As WinForm.CheckBox = e.Form.Controls("完成后打开指定目录")
    If dk.Checked=True  Then
        Proc.File = ProjectPath & "Reports\\" \'指定要打开的文件
        Proc.Start()
    End If
End If

--  作者:有点蓝
--  发布时间:2021/7/22 13:37:00
--  
没有数据吧

Dim Products As List(Of String)
Products = DataTables("数据表").SQLGetValues("d5","","d5")
msgbox(Products.Count)
If Products.Count > 0 Then
msgbox(1)
    For i = 0 To Products.Count - 1
        Dim Products1 As List(Of String)

--  作者:cnsjroom
--  发布时间:2021/7/22 16:00:00
--  回复:(有点蓝)没有数据吧Dim Products As List(Of ...
老师  是有数据的  红色部分的代码也可以对应生成excel表文件到指定的目录下  

然后一直到把符合条件的数据都写出来后   程序一直处于运行状态   无法停止也无法终止了……只有任务管理器关闭项目
[此贴子已经被作者于2021/7/22 16:03:53编辑过]

--  作者:有点蓝
--  发布时间:2021/7/22 16:04:00
--  
MessageBox.Show("单个表已经生成!","温馨提示")如果没有弹出来,肯定没有执行,或者中间出错了
--  作者:cnsjroom
--  发布时间:2021/7/22 16:06:00
--  回复:(有点蓝)MessageBox.Show("单个表已经生成!",...
如果红色部分单独注释掉  又可以弹出 

红色部分单独执行  也能够运行红色部分代码所实现的功能


现在组合起来就不能运行了    老师可以帮忙看看不呢?

以下内容是专门发给有点蓝浏览



[此贴子已经被作者于2021/7/22 16:07:42编辑过]

--  作者:有点蓝
--  发布时间:2021/7/22 16:58:00
--  
多嵌了一个循环,去掉For i = 0 To Products.Count - 1
--  作者:cnsjroom
--  发布时间:2021/7/22 17:35:00
--  回复:(有点蓝)多嵌了一个循环,去掉For i = 0 To P...
谢谢老师的耐心指导   取消后   全部正常了