0

I'm trying to list the results of a LookUpSet only if they are in another string. Initially I used the following to get an array of strings seperated by a semi-colon.

Join(LookUpSet(...),";")

The next stage was to test if the strings were in the main string. I tried nesting the return value inside an IIF statement;

Join(LookUpSet(...,IIF(InStr(Fields!BigText.Value,Fields!Text.Value) > 0, Fields!Text.Value, Nothing),...),";")

I understand this doesn't work because the big string that I am comparing against is in my first dataset and the other is in my second dataset

Next I tried to use InStr on the results of the LookUpSet;

IIF(InStr(Fields!BigText.Value, LookUpSet()) > 0, LookUpSet(), Nothing)

This won't work either so I've tried to create custom code and am nearly there;

Code.CheckSetInString(Fields!BigText.Value, LookUpSet())

The code is below, when debugging I receive "Object reference not set to an instance of an object", but can't see anything that I've failed to declare.

How should I troubleshoot which object isn't declared? The custom code is below for reference.

Function CheckSetInString(ByVal str As String, ByVal setofstrings As Object())


If setofstrings Is Nothing OrElse Not setofstrings.length > 0 Then
    Return Nothing
End If


Dim returnedstrings AS [String]()
Dim i As Integer = 0

    For Each item As String In setofstrings

        If InStr(1, str, item, 1) > 0 Then

            returnedstrings(i) = item
            i += 1

        End If
    Next


Return returnedstrings


End Function

Any advice is appreciated, Dan

Dan
  • 111
  • 10
  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Visual Vincent Feb 20 '18 at 16:01
  • Hi Vincent, It helps with my understanding, but I've been unable to fix it. Have you got any recommended reading on custom VB in SSRS? – Dan Feb 22 '18 at 14:39
  • Unfortunately I haven't worked with SSRS. If you (despite reading at least the two top-voted answers on the post I linked to) cannot find the source of the problem, then I'm afraid I can't help you. The best advice I can give you is to hover over your variables when the exception occurs to see what their values are, and inspect them in the [**Autos or Locals windows**](https://msdn.microsoft.com/en-us/library/bhawk8xd.aspx). – Visual Vincent Feb 22 '18 at 14:56

0 Answers0