Should be okay if it is the same type. You will need to format the new drive, and re-install a operating system. That's if the replacement 40gb h/d as never been used before.
You could also keep your old drive as a slave unit, if there is space in the case, and run both drives piggy-back fashion.
What operating system are you using, as this could make a slight difference, in setting-up!.