Can you have something like this:
Do While True
strVarName = ds.Tables("MyTable")(iRow)("varname")
strVarValue = ds.Tables("MyTable")(iRow)("varvalue")
If Execute(strVarName, strVarValue) Then Exit Do
'If the function returns True, the loop will exit.
Loop
Private Function Execute(ByVal sVarName As String, ByVal sVarValue As String) As Boolean
'Your code here
End Function
Or am I grossly misunderstanding the question?