How to check if Data Table String Contains Number Variable

I have a Output Data table activity which has converted a select in a Data Table to String.


I also have a variable named NumberCheck which is assigned as Int32 and has a value of 5.

How do i make a if statement that can check if the Int32 variable exists in the above string?

The query i have doesn’t work:

If CInt(Datatable2).Contains(NumberCheck)

The error stated is Contain is not a member of ‘Integer’.

If i do NumberCheck.ToString then it works but it sees 35 as 5 and gives true being text.


Why you are converting DataTable into string.

You can use ForEach Row activity to iterate DataTable and then check whether this DataTable contains required value or not. i.e.NumberCheck

ForEach row in yourDT
If Cint(row(“Column name”).Tostring) = Number heck
Then print True
Else print False

I wanted to avoid a ForEach loop because what i gave was an example. I need to iterate over 1000 columns with number data and contain would do it straight away.

Is there any other way?



  newDT = yourDT.Select("ColumnName = '"+NumberCheck.Tostring+"').CopyToDataTable

If newDT.Rows.Count > 0
Then it contains that value
Else no


What if the columns have no header and are [F1], [F2], [F3], [F4], etc…

How does it iterate through all the columns please?


Try below LINQ query.

  newDT = yourDT.AsEnumerable.Where(Function(row) Cint(row.Item(5).ToString) = 5).CopyToDataTable

Here 5 refers to F column.


Sorry I don’t understand. Could you make a small project to show me with data table please.


refer below xaml

After converting string use below code in log or message box


Main.xaml (8.1 KB)

1 Like


Thank you so much. This worked perfectly.

1 Like

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