Generally Speaking
Generally speaking, the proper thing to do if your question is essentially the same as the old one is to edit your old question to add your code. When people repost the same question chances are that someone is going to notice that it is the same question and they will flag the post as duplicate or vote to close it as duplicate. When the duplicate is from the same user as the user who posted the original question, downvotes are sure to accompany the flagging or vote to close.
In one case I've noticed a user who reposted their question but took care to delete the original one, perhaps thinking that their deed would go unnoticed. They did not realize that users with >= 10K of reputations can see deleted posts. These shenanigans earned them downvotes on the repost and votes for closure (because the post was suffering from issues quite independent from it being a repost).
The lesson here is don't repost unless you want a negative response.
Your Case
I notice that your question already has an accepted answer. And this answer is responding to what you've put in your question. It would be a cheap thing to do to the person who has already helped you and whose answer you've accepted if you changed your question in such a way that their answer looks like it is not actually answering your question, or that it is lazy answer.
Proceed with caution if you decide to edit the old one.