Can you please tell me why this line of code gives error:- "Object reference not set to instance of an object" 

```
 searchstr = IIf(
    Not searchstr Is Nothing
    AndAlso searchstr.Length > 0,
    searchstr.Replace("Desig_id", "designation_id"), "")  

```

Also can you provide alternative to make this type of validation?