You're doing it correctly. I don't think it's doing what you think it is, but rather it just seems that way.

Put a breakpoint on the If...Then line, and step through when ret is True. Dollars to donuts says that the myip = "" doesn't execute, but that myip is already empty.