1) You have to calculate IP. the intersection point
2) You should check that IP is between A and B
3) You had the vector V, and now have the vector (IP-P),
4) You can choose betwwen two options:
a) Now you can compare the vector lenghts to now if V is greater that (IP-P)
b) Calculate t as I described before...
if t==0 => V=(0,0);
if t=1 => V=(IP-P)
if (t>0 && t<1) length(V) < length(IP-P)
if (t>1) length(V) > length(IP-P)