You got stuck with second method because you're using an incorrect Newton's Equation of Motion. The correct  one is (the object travels on the $x$ axis):

$$ma=F-kx$$
$$m\ddot{x}+kx-F=0$$

But it's very clear that the method of conservation of energy is far simpler. Have a look at this derivation.

Substitute:

$$kx-F=X$$
So:
$$k\dot{x}=\dot{X}$$
$$k\ddot{x}=\ddot{X}\implies \ddot{x}=\frac1k\ddot{X}$$
$$\frac{m}{k}\ddot{X}+X=0$$
$$\ddot{X}+\frac kmX=0$$

Set:

$$\frac km=\omega^2$$

$$\ddot{X}+\omega^2 X=0$$
This classic differential equation solves to:

 $$X(t)=A\cos(\omega t+\phi)$$
Where $A$ and $\phi$ are constants (amplitude and phase angle, resp.) that we determine from the *initial conditions*. So:

Assume at $t=0$, $x=0 \implies X(0)=-F$

$$-F=A\cos\phi$$
Assume at $t=0, \dot{x}=0 \implies \dot{X}(0)=0$.

$$\dot{X}=-A\omega\sin(\omega t+\phi)$$
$$\dot{X}(0)=-A\omega\sin(\phi)=0\implies \phi=0$$
$$A=-F$$
$$X(t)=-F\cos\omega t=kx(t)-F$$
$$x(t)=\frac Fk(1-\cos\omega t)$$
So this is the equation of motion.
And this is the expression for velocity in time:
$$\dot{x}=\frac Fk \omega \sin \omega t$$

Use these to find the time needed to travel the distance $b$, then use that time, say $t_b$, to determine $\dot{x}(t_b)$ with the velocity expression.

So that's quite a kerfuffle, compared to the conservation method, which explains why your textbook recommends it.