May 9, 2013 at 4:47 am
I have a function that loops through a recordset doing bespoke customisations. For some reason it appears to have stopped working and I cannot see where the problem is.
Can anyone help?
The code is:
Public Function Localisation(UKString As String) As String
Dim LocalString As New System.Text.StringBuilder(UKString)
Dim i as Integer
If UKString = "" Or IsNothing(UKString) Then
Return UKString
Else
i = 0
For i = 1 to Report.Parameters!Localisations.Count()
If UKString.Contains(Report.Parameters!Localisations.Value(i)) Then
LocalString.Replace(Report.Parameters!Localisations.Value(i).ToString(), Report.Parameters!Localisations.Label(i).ToString())
Exit For
End If
Next i
Return LocalString.ToString()
End If
End Function
It uses a hidden multiselect dataset as the list of customisations, and the sp that produces the set unions a dummy value to ensure that the code always has a set to loop, even if that's just one record. I know this returns data correctly, so the problem isnt the dataset.
The problem is on the LocalString.Replace line, but no matter what I try, I can't get it working again. I had it running previously, but not now.
Any help would be appreciated.
May 9, 2013 at 8:48 am
I don't know if I'm allowed to answer my own questions, but I've solved the problem.
The issue is that the Parameters collection is zero based and not 1 based. The error would occur when the customisation was not found, so I changed the for loop to be 0 to Parameters!Localisations.Count() - 1 and everything works nicely.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply