As pointed out by Cosmin Prund, the problem is visibility.
TForm has a procedure called Next that does not accept any parameters.
Your function uses the same name and, as you call the function in the implementation of the TForm1 class, the compiler processes the call as TForm1.Next and therefore it gives an error.
To solve the problem, precede the device name with the function name ie, Unit1.Next() .
So this should be your code
if label1.Caption = '' then res := Unit1.next('current', 'next');
source share