In Excel, First column consists of 3 bananas , 2nd 3 apple and 3rd 3 oranges
Bot should check how many bananas, apples, orange are their? Count it
Add one other fruit name(Mango) at one of the banana place& run , show me the count of mango and banana now
Anyone please help me with code?
lrtetala
(Lakshman Reddy)
August 12, 2024, 4:41pm
2
Hi @Shravan_Pintu
bananaCount = dt.AsEnumerable().Count(Function(row) row("Column1").ToString.Equals("banana", StringComparison.OrdinalIgnoreCase))
appleCount = dt.AsEnumerable().Count(Function(row) row("Column1").ToString.Equals("apple", StringComparison.OrdinalIgnoreCase))
orangeCount = dt.AsEnumerable().Count(Function(row) row("Column1").ToString.Equals("orange", StringComparison.OrdinalIgnoreCase))
Regards,
lrtetala
(Lakshman Reddy)
August 12, 2024, 5:24pm
3
@Shravan_Pintu
Shravan_Pintu:
Bot should check how many bananas, apples, orange are their? Count it
Input:
Output:
mangoCount = dt.AsEnumerable().Count(Function(row) row("Fruits").ToString.Equals("mango", StringComparison.OrdinalIgnoreCase))
Input:
Output:
Regards,
Here Bot should replace one banana row with a mango & should check the count
lrtetala
(Lakshman Reddy)
August 12, 2024, 5:59pm
5
@Shravan_Pintu
Try this
Invoke Code:
' Find the first occurrence of "Banana" and replace it with "Mango"
Dim firstRow = (From row In dt.AsEnumerable()
Where row.Field(Of String)("Fruits") = "Banana"
Select row).FirstOrDefault()
If firstRow IsNot Nothing Then
firstRow("Fruits") = "Mango"
End If
Input:
Output:
Sequence16.xaml (14.0 KB)
Regards,
1 Like
system
(system)
Closed
August 15, 2024, 6:00pm
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.