Serial port coding Problem

I am trying to write a code to communicate with a summagraphics summasketch III Tablet, I start following the instructions in the Serial port Tutorial from Geoff Perlman and I can not make it work.
The Tablet is connected to my pc running Win10 through a serial to usb cable and tested for connection with TabletWorks, and it works.
After running the tutorial code, it gives a “An exception of class Out of Bounds” error following the plug and unplug of the Tablet. If I run the code with the Tablet connected it recognize the Tablet in COM4 port, but after this do not work.
Could someone help on this?