Obj ref error

I am using a If condition in a Foreachloop to assign a value. but i am getting Object reference not set to an instance of an object error.

Below is the If condition

Not(String.IsNullOrEmpty(str_JDELineDesc.Trim)) And Not(String.IsNullOrEmpty(str_JDEAmountType.Trim)) And Not(String.Equals( str_JDEAmountType,“No Entry”)) AND NOT(String.IsNullOrEmpty(item.ToString.Trim)) AND NOT(String.IsNullOrEmpty(compareValue.Trim)) AND compareValue.Trim.Equals(str_JDELineDesc.Trim)

Hi @vamsi.battulaus008

An error appears to occur by proceeding with the “trim” method without the initial value. It seems necessary to remove the trim or declare the initial value.



Can you try the following expression?

item isnot Nothing AndAlso   Not(String.IsNullOrWhiteSpace(str_JDELineDesc)) AndAlso Not(String.IsNullOrWhiteSpace(str_JDEAmountType)) AndAlso Not(String.Equals( str_JDEAmountType,“No Entry”)) AndAlso NOT(String.IsNullOrWhiteSpace(item.ToString)) AndAlso NOT(String.IsNullOrWhiteSpace(compareValue)) AndAlso compareValue.Trim.Equals(str_JDELineDesc.Trim)


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