Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

593
Views
To use IIF() for checking a length of spliited string before calling GetValue(), is still error

In rdlc report. A subreport was created 4 parameters for received from main report. But sometime a main report may send less than four value. For example: A String was sent from these VB.Net code.

Dim strProcessCode As String = {"A,B"}

A string includes only two value.(A and B) So I using splitted this string by using expression for each parameter like these

=iif(Split(Parameters!pProcessCode.Value, ",").Length>0,
           (Split(Parameters!pProcessCode.Value, ",")).GetValue(0)
           ,nothing)   ''For first parameter

First and second parameters is fine. But It has a problem when I prepared a value for third parameter. Despite it used the same way.

    =iif(Split(Parameters!pProcessCode.Value, ",").Length>2,
           (Split(Parameters!pProcessCode.Value, ",")).GetValue(2)
           ,nothing)   ''For third parameter

It show this error message

Error: Subreport could not shown.

How to fixed it?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It would be easier to read and maintain if you could break it down into an If.. ElseIF.. Else or a Select.

Function ReturnResult(byval pProcessCodeValue as string) as string
    If Instr(0, pProcessCodeValue,",",vbTextCompare) = 0 Then
       ReturnResult = pProcessCodeValue
       Exit Function
    End If 
    dim arr() as string
    arr = Split(pProcessCodeValue , ",")
    ReturnResult = arr(arr.Length)
End Function

Call it:

=ReturnResult(Parameters!pProcessCode.Value)

However, with SSRS you may need to use nested IIF's, eg:

=iif(Split(Parameters!pProcessCode.Value, ",").Length = 0,
       (Split(Parameters!pProcessCode.Value, ",")).GetValue(0)
       , iif(Split(Parameters!pProcessCode.Value, ",").Length = 1,
       (Split(Parameters!pProcessCode.Value, ",")).GetValue(1)
       , iif(Split(Parameters!pProcessCode.Value, ",").Length = 2,
       (Split(Parameters!pProcessCode.Value, ",")).GetValue(2)
       , nothing)) 
    ) 
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!