我把代码分成6段,用MessageBox.Show()来显示运行部位。
程序运行显示到MessageBox.Show(3)后,就直接显示MessageBox.Show(7),结束了程序。
从“If dr IsNot Nothing”往后没有再运行,但也没有出现错误提示。是不是IsNot Nothing...
请专家指教!代码如下:
'生成word报表:
Dim clbx1 As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox1")
Dim clbx2 As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox2")
For Each j As String In clbx2.CheckedIndices
Dim tm As String = ProjectPath & "模板文件\" & clbx2.Items(j) '指定模板文件
For Each i As Integer In clbx1.CheckedIndices
Dim fl As String = ProjectPath & "成品文件\" & clbx1.items(i) & clbx2.Items(j) '指定目标文件
MessageBox.Show(1)
'文件已经存在,是否覆盖重新填写
If FileSys.FileExists(fl) Then
If MessageBox.Show(fl & "文件已经存在,是否覆盖重新填写?","提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.No Then
Continue For
End If
End If
Dim nm As String = CurrentTable.Name
Dim dr As DataRow = DataTables(nm).Find("名称 = '" & clbx1.items(i) & "'")
--------------------------------------以下代码不运行
'写入模板
If dr IsNot Nothing
Dim wrt As New WordReport(Tables(nm),tm,fl) '定义一个WordReport
wrt.BuildOne(dr)
wrt.quit
End If
Next
Next
[此贴子已经被作者于2016/9/4 20:31:29编辑过]