For Each 循环变量 As 变量类型 In 集合 代码Next
所以您应该:
For Each dt As DataTable In DataTables If dt.Name <> "表1" And dt.Name <> "表2" Then MessageBox.show(dt.name) End IfNext