You want to change the value of the image number within the function, each time the function is called?
To do that, you would need to define the variable as global (outside the function), then increase it by one within the function. Something like this:
global imagenumber
do
dostuff(argument1,argument2)
wait key
cls
loop
function dostuff(parameter1,parameter2)
returnvalue=whateveryouwanttodowiththeparameters
imagenumber=imagenumber+1
text 0,0,str$(imagenumber)
endfunction returnvalue
This makes the function increase the value of the image number and display it on the screen each time you press a key. (Note that you can't include the global variable as an argument of the function.)