For each set, you have to check the from and to is not within the range of another set.

so say new set is has two vars: New_Min and New_Max

class set

public property min as int

public property max as int

public property RowID as int

end class

public function can_add_or_change(RowID) as Boolean

Dim can_add as boolean = true

Dim sets as new List(of set)

for each s in sets

if (new_min >= s.min or new_min <= s.max or new_max >= s.min or new_max <= s.max) and s.Row_Id <> rowID

can_add = false

exit for

end if

next

if can_add

sets(RowId).min = newmin

sets(RowID).Max = newmax

return true

else

'Let user know they have made a mistake

return false

end if

end function

Then it's just a matter of keeping track of the list. Let each row number be the rowID. Update the rows as necessary within the list. Using the logic of can_add to guide you.

so say new set is has two vars: New_Min and New_Max

class set

public property min as int

public property max as int

public property RowID as int

end class

public function can_add_or_change(RowID) as Boolean

Dim can_add as boolean = true

Dim sets as new List(of set)

for each s in sets

if (new_min >= s.min or new_min <= s.max or new_max >= s.min or new_max <= s.max) and s.Row_Id <> rowID

can_add = false

exit for

end if

next

if can_add

sets(RowId).min = newmin

sets(RowID).Max = newmax

return true

else

'Let user know they have made a mistake

return false

end if

end function

Then it's just a matter of keeping track of the list. Let each row number be the rowID. Update the rows as necessary within the list. Using the logic of can_add to guide you.