0
我知道这是一个相对常见的错误,但我正在一个应用程序中允许使用vb.net或C#编写自定义报告进行脚本编写。错误处理非常差,我不知道如何添加我自己的(如果它甚至可能)。异常已被调用的目标引发
我的代码只是检索存储在格式为的报告上的文本框中的值,名字并截断了逗号后的所有字符。此值姓氏被放置在报告上的新文本框中。这是我的代码:
Sub Detail1_Format
Dim lastNameFirstName As String = ""
Dim lastName As String = ""
Dim lastNameCommaIndex As Integer=
'set lastNameFirstName value from data on report'
lastNameFirstName = ReportUtilities.ReturnTextBoxValue(rpt,"Detail1","txtdtr_DTOOLS_CompanyName")
'find index of first comma in lastNameFirstName string'
lastNameCommaIndex = lastNameFirstName.IndexOf(",")
'set contents of lastName using substring of lastNameFirstString'
lastName = lastNameFirstName.SubString(0, lastNameCommaIndex)
'the error happens above when I use lastNameCommaIndex'
'to set the number of characters in my substring'
'set client name textbox value using lastName'
ReportUtilities.SetTextBoxValue(rpt,"Detail1","txtdtr_CALC_ClientName",lastName)
End Sub
当我使用lastNameCommaIndex来设置我的子字符串中的字符数时会发生错误。如果我用一个数字替换它,报告就会正确发布。
OK太好了!我完全按照您的显示进行了尝试,并且收到有关.IsNullOrWhiteSpace()不是String成员的错误。我认为这可能是应用程序中.NET支持的未知版本的限制。所以我只是在If语句的上下文之外使用了.split代码,因为总会有一个值。完美的作品。谢谢! – fryeguy 2011-01-21 22:27:39