Studio - Getting this error and exception with 'If'

Hello,
I’m on Studio.
I have an Excel with only 3 columns. One column is “Company Name”.
I’m reading it into a DataTable. I want to get the names of the companies with names that contains ‘brok’.

In the For loop, I have If condition like this:
CurrentRow.Item(“Company Name”).ToString.Contains(“brok”) AndAlso NOT string.IsNullOrEmpty (CurrentRow.Item(“Company Name”).ToString)

It gives an error at Runtime only - Object Reference not set to an instance of an object.

@Prinal_C
its better to check if value is null befor testing the value

give a try on following:

Not (isNothing(CurrentRow("Company Name")) OrElse Not CurrentRow("Company Name").toString.Contains("brok"))
1 Like

@ppr – still getting the same error.

It worked now. Thank you !

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