' Assuming dtAnimal and dtMaster are the input DataTables
Dim dtResult As New DataTable
dtResult.Columns.Add("Animal", GetType(String))
dtResult.Columns.Add("ID", GetType(String))
' List of dynamic vaccines to check
Dim vaccinesToCheck As New List(Of String) From {"305", "308", "306", "300"}
' Iterate through each row in dtAnimal
For Each rowAnimal As DataRow In dtAnimal.Rows
Dim animal As String = rowAnimal("Animal").ToString()
' Check if the dtMaster contains a row with the matching animal and any of the dynamic vaccines
Dim matchingRows As DataRow() = dtMaster.Select($"Animal = '{animal}' AND Vaccine IN ('{String.Join("','", vaccinesToCheck)}')")
' Determine the ID based on the condition
Dim id As String
If matchingRows.Length > 0 Then
id = "Changed"
Else
id = "Checking"
End If
' Add the result to dtResult
dtResult.Rows.Add(animal, id)
Next
' Now dtResult contains the expected result
output_Dt=dtResult