3

Can someone help me determine which I should be using?

Here is the situation - I am pulling a value from a column in the Data Table. If there is anything in that column, I set the data to a variable and take an action. If the column is blank, I want to skip that.

I am confused as to which IsWHATEVER statement would be best. For Example:

If IsEmpty(Datatable.Value("M4","Data_Entry"))=False Then

OR

If IsNull(Datatable.Value("M4","Data_Entry"))=False Then

OR

If IsNothing(Datatable.Value("M4","Data_Entry"))=False Then

Suggestions?

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
James Craig
  • 473
  • 3
  • 9
  • 22

2 Answers2

2

I've just tried all of your options and found this to be the most correct:

If (DataTable.Value("M4","Global") <> "") Then

Your original options will not work on QTP Datatables as these are for uninitialised objects or variables. However, in QTP as soon as you create a parameter in the Datatable the first value gets initialised as blank (not to be confused with empty).

shreyansp
  • 723
  • 1
  • 7
  • 16
0

I agree with shreyansp.. The 3 options are for variables and objects

You could also use the below expression

If len(trim(DataTable.Value("M4","Global"))>0 Then
   'Do code here
End If
karthik27
  • 484
  • 1
  • 4
  • 12