Dim Book As New XLS.Book(ProjectPath & "Attachments\晨午检上报表.xlsx")Dim fl As String = ProjectPath & "Reports\晨午检上报表.xlsx"Dim s As String = ""For Each r As Row In Tables("晨午检").GetCheckedRows s =s & "," & r("_Identify")Nexts = s.Trim(",")Tables("晨午检").Filter = "[_Identify] in (" & s & ")"Book.Build() '生成细节区Book.Save(fl) '保存工作簿Dim Proc As New Process '打开工作簿Proc.File = flProc.Verb = "Print" '指定动作Proc.Start()
勾选任意行打印没问题,但是在没有勾选行的前提下,显示错误:“语法错误: IN 关键字后面必须是由逗号分隔的非空表达式列表,并且必须用括号括起来。” 这个怎么修改呢?
既然都知道原因了,就不能加个判断吗
Dim s As String = ""dim rs as list(of row) = Tables("晨午检").GetCheckedRows
if rs.count = 0 then
msgbox("没有")
return
end if
For Each r As Row In rs
s =s & "," & r("_Identify")
Next
s = s.Trim(",")
老师:您好! 我按照您的指导意见,写的代码出现了错误信息,烦请再帮助一下。
Dim Result As DialogResult
Dim b As WinForm.TextBox = e.Form.Controls("TextBox1")
'b.BackColor = Color.Red
Dim gzh As String = b.Value
Dim Book As New XLS.Book(ProjectPath & "Attachments\生产工艺加工流程卡模板.xls")
Dim fl As String = ProjectPath & "Reports\打印工艺卡.xls"
Dim s As String = ""
Dim rs As list(Of Row) = Tables("生产计划明细表").GetCheckedRows
If rs.count = 0 Then
msgbox("没有勾选")
Return
End If
For Each r As Row In Tables("生产计划明细表").GetCheckedRows
s = s & "," & r("_Identify")
Next
s = s.Trim(",")
Tables("生产计划明细表").Filter = "[_Identify] in (" & s & ")"
Book.Build() '生成细节区
Book.Save(fl) '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File = fl
'Proc.Verb = "Print" '指定动作
Proc.Start()
我 选中的记录和错误信息请看图片。
此主题相关图片如下:打印卡2.jpg