# Invoke Code error - For each row and IF statements

I have build the below code in side Invoke code( VBnet). There is a (statement expected error) coming at the end of if block and after next( row 21 to23)
Test6.xaml (6.2 KB)
. Please refer to the below screenshot: Dim table As New DataTable

Dim table2 As New DataTable
table2 = dt2.Select("[Agency]=‘Airan’ AND [PrePostCol] =‘Post’ AND [Audit result] = ‘FAILED’ AND [Audit Date]=" + strAuditDate).CopyToDataTable

Dim table3 As New DataTable
table3 = table2.DefaultView.ToTable(True,“Agent ID”)

Dim row1 As DataRow
For Each row1 In table3.Rows
Dim strAgent As String
strAgent = row1.Item(0).ToString
Dim noOfFatal As Integer = 0
Dim noOfNonFatal As Integer = 0
For Each row2 As DataRow In table2.Rows
If(row1.Item(“Agent ID”)= row2.Item(“Agent ID”)) Then
If(row2.Item(“Fatal/Non-Fatal Error”)) Then noOfFatal = noOfFatal + 1 End If
If(row2.Item(“Fatal/Non-Fatal Error”)) Then noOfNonFatal = noOfNonFatal + 1 End If
End If
Next row1
noOfFatal = 0
noOfNonFatal = 0
Next row1

out_table = table

Can you tell me what is the error for? I have checked the syntax for IF and For each seems ok.

.xaml is attached

@shrayud

Try below code

Dim table As New DataTable

Dim table2 As New DataTable
table2 = dt2.Select("[Agency]=‘Airan’ AND [PrePostCol] =‘Post’ AND [Audit result] = ‘FAILED’ AND [Audit Date]=" + strAuditDate).CopyToDataTable

Dim table3 As New DataTable
table3 = table2.DefaultView.ToTable(True,“Agent ID”)

Dim row1 As DataRow
For Each row1 In table3.Rows
Dim strAgent As String
strAgent = row1.Item(0).ToString
Dim noOfFatal As Integer = 0
Dim noOfNonFatal As Integer = 0
For Each row2 As DataRow In table2.Rows
If(row1.Item(“Agent ID”)= row2.Item(“Agent ID”)) Then
If(row2.Item(“Fatal/Non-Fatal Error”)) Then
noOfFatal = noOfFatal + 1
End If
If(row2.Item(“Fatal/Non-Fatal Error”)) Then
noOfNonFatal = noOfNonFatal + 1
End If
End If
Next row1
{"ft_lang_label":"__label__en","ft_lang_prob":0.5841544,"math_prob":0.93643516,"size":1294,"snap":"2021-43-2021-49","text_gpt3_token_len":386,"char_repetition_ratio":0.13565892,"word_repetition_ratio":0.0,"special_character_ratio":0.26893353,"punctuation_ratio":0.13654618,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9802747,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-12-05T10:26:15Z\",\"WARC-Record-ID\":\"<urn:uuid:ad1def90-98c2-4075-acf4-7c2251736602>\",\"Content-Length\":\"44165\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:55418503-5964-4987-b3bb-2787241f235c>\",\"WARC-Concurrent-To\":\"<urn:uuid:b1cc4830-892a-4ef1-9482-a9851026cded>\",\"WARC-IP-Address\":\"184.105.176.42\",\"WARC-Target-URI\":\"https://forum.uipath.com/t/invoke-code-error-for-each-row-and-if-statements/346121\",\"WARC-Payload-Digest\":\"sha1:TGFBSXGJXE3RHI4JOZ5XJCOVYPTAXYKY\",\"WARC-Block-Digest\":\"sha1:ZDFFZSZJ7J2CXIGTEUBSCZWAKAYARCML\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964363157.32_warc_CC-MAIN-20211205100135-20211205130135-00438.warc.gz\"}"}