Hi
OK, try this stand alone example and see if it helps. Edit values as needed to test and clcik button for results.
' new test Project with:
' Form1
' Datagridview named DGV
' Button1
Option Strict On
Option Explicit On
Public Class Form1
Dim V As New DataTable("Freddy")
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' set up a series of test values
With V
.Columns.Add("arg0", GetType(Integer))
.Columns.Add("arg1", GetType(Integer))
.Columns.Add("arg2", GetType(Integer))
.Columns.Add("arg3", GetType(Integer))
.Columns.Add("result", GetType(String))
.Rows.Add(22, 0, 11, 111)
.Rows.Add(23, 0, 11, 112)
.Rows.Add(24, 0, 10, 113)
End With
DGV.DataSource = V
End Sub
Function CheckThem(arg0 As Integer, arg1 As Integer, arg2 As Integer, arg3 As Integer) As String
' need to choose appropriate initial values
Static arg0h As Integer = 0
Static arg1h As Integer = 0
Static arg2h As Integer = 1000
Static arg3h As Integer = -1
Dim ret As String = "Error"
If ((arg0 > arg0h) And (arg1 = 0) And ((arg2 <= arg2h) And arg3 <> arg3h And arg3 < 200)) Then ret = "H&H"
arg0h = arg0
arg1h = arg1 ' just for completeness
arg2h = arg2
arg3h = arg3
Return ret
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For i As Integer = 0 To V.Rows.Count - 1
V(i)("result") = CheckThem(CInt(V(i)("arg0")), CInt(V(i)("arg1")), CInt(V(i)("arg2")), CInt(V(i)("arg3")))
Next
End Sub
End Class