如何设置程序基础报表的多个参数,特别是一个功能 [英] How can I set multiple parameter of procedure base reports in particular one function
本文介绍了如何设置程序基础报表的多个参数,特别是一个功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Private Sub LoadProcedureBaseReports(Optional ByVal param As String = "")
Dim intCounter As Integer
Dim intCounter1 As Integer
Dim strParValPair() As String
Dim strVal() As String
Dim index As Integer
Try
crv.ShowGroupTreeButton = False
'Load Reports
Me.Cursor = Cursors.WaitCursor
strPath = System.Configuration.ConfigurationSettings.AppSettings("ReportFilePath")
strRptName = strPath & "\" & strRptName
rptdoc.Load(strRptName)
rptdoc.SummaryInfo.ReportTitle = ReportTitle
rptdoc.SummaryInfo.ReportAuthor = ReportAuthor
'Check there are parameter or not
intCounter = rptdoc.DataDefinition.ParameterFields.Count
If intCounter = 1 Then
If InStr(rptdoc.DataDefinition.ParameterFields(0).ParameterFieldName, ".", CompareMethod.Text) > 0 Then
intCounter = 0
End If
End If
If intCounter > 0 And Trim(param) <> "" Then
strParValPair = param.Split("&")
For index = 0 To UBound(strParValPair)
If InStr(strParValPair(index), "=") > 0 Then
strVal = strParValPair(index).Split("=")
paraValue.Value = strVal(1)
currValue = rptdoc.DataDefinition.ParameterFields(strVal(0)).CurrentValues
currValue.Add(paraValue)
rptdoc.DataDefinition.ParameterFields(strVal(0)).ApplyCurrentValues(currValue)
End If
Next
End If
objCommon.cnToSqlServer()
For intCount = 0 To rptdoc.Database.Tables.Count - 1
rptdoc.Database.Tables(intCount).ApplyLogOnInfo(tlicurrent)
Next intCount
''Sub Reports
'For index = 0 To objReport.ReportDefinition.Sections.Count - 1
' For intCounter = 0 To _
' objReport.ReportDefinition.Sections(index).ReportObjects.Count - 1
' With objReport.ReportDefinition.Sections(index)
' If .ReportObjects(intCounter).Kind = _
' CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
' mySubReportObject = CType(.ReportObjects(intCounter), _
' CrystalDecisions.CrystalReports.Engine.SubreportObject)
' mySubRepDoc = _
' mySubReportObject.OpenSubreport(mySubReportObject.SubreportName)
' For intCounter1 = 0 To mySubRepDoc.Database.Tables.Count - 1
' mySubRepDoc.Database.Tables(intCounter1).ApplyLogOnInfo(ConInfo)
' mySubRepDoc.Database.Tables(intCounter1).ApplyLogOnInfo(ConInfo)
' Next
' End If
' End With
' Next
'Next
'selection formula
If strSelectionFormula.Length > 0 Then
rptdoc.RecordSelectionFormula = strSelectionFormula
End If
crv.ReportSource = Nothing
crv.ReportSource = rptdoc
Application.DoEvents()
crv.Zoom(125)
Me.Cursor = Cursors.Default
If BlnPrintReport Then
Dim e As System.Windows.Forms.ToolBarButtonClickEventArgs
objPrint = True
ToolBar2_ButtonClick(ToolBar2, e)
objPrint = False
newReportForm = Nothing
Me.Close()
End If
Catch ex As Exception
ErrorHandler(ex.Message, Me.Name, "LoadProcedureBaseReports")
End Try
End Sub
我想将param设置为对象,并希望通过它传递不同的数据类型参数......
谁能知道这是可能的,那么怎么
下面的代码我可以传递字符串..........
请......
I want to set param as object and in that I wan to pass different datatype argument...........
Can any one know is it possible and yes then how
below code i can pass string..........
pls..........
推荐答案
您可以使用ParamArray.
You could use the ParamArray.
Private Sub LoadProcedureBaseReports(ByVal ParamArray param())
然后,您只需调用
之类的函数即可
Then you just call the function like
LoadProcedureBaseReports("a string", 1, 1.234)
这篇关于如何设置程序基础报表的多个参数,特别是一个功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文