Index and length must refer to a location within the string. Parameter name: length in Assign

Hi ,
with regards to the below post -

I am using this code -

(From d In dtData.AsEnumerable
Let sc = strCUR.Trim.Substring(0,2).toUpper
Let sa = strACC.Trim.Substring(strACC.Trim.Length - 4).toUpper
Let rm = d(“Remit_ID”).toString.Trim.toUpper
Where rm.StartsWith(sc) Or rm.EndsWith(sa)
Let cm2 = Convert.ToInt32(rm.StartsWith(sc)).toString
Let cm1 = Convert.ToInt32( rm.EndsWith(sa)).toString
Let msk = CInt(cm1 & cm2)
Where msk > 0
Order By msk Descending
Select v = d(“Supplier_ID”).toString).DefaultIfEmpty(“No record found”).First()

but I am getting
Assign: Index and length must refer to a location within the string. Parameter name: length

Can you let me know where do I need to change my code?

@ppr

Regards,
Gokul

check the values of the strCur / strACC as they are involved in index / length actions

d(“Supplier_ID”).toString).DefaultIfEmpty(“No record found”).First()

Here you are short with the starting parenthesis
change it to below

(d(“Supplier_ID”).toString).DefaultIfEmpty(“No record found”).First()
or
(d(“Supplier_ID”).toString).DefaultIfEmpty(“No record found”).First()

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.