I copied and pasted it myself (just to be sure) into both QBasic, and QB64. It worked perfectly in both. Do you get an error when you run it, and if so, what is the error? It may just be a copy/paste problem. Another possibility is that you are using an older version of QB64 which doesn't handle certain QBasic code.
In any case, if you're more comfortable with C++, that's not such a bad thing, either. Unfortunately, I don't have the code in C++.