Yes, you need to take a sample to the Vet and get the proper medication. If they look kind of splice spaghetti, they are probably round worms. That is not healthy fir the dog and could cause major problems.
You need to take a "fresh" piece of the stool sample
into your vet in a small plastic zip lock bag,they will
check it for the tyoe of worms your dog has and give
medication.
IT IS NOT GOOD when a dog throws up worms,this
could mean he has A LOT of worms in his system/
body and should be ASAP as worms can kill a dog.
Jan