Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

597
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda