When you get that particular message, take a close look at the line that is causing the error. The only way that can happen is if one of the objects is Nothing. Find the object that is Nothing, and all will be well. In this case, there are only two objects in the statement: SerialPort and testArray. Highlight each in turn and you will find that one of them is Nothing (you may have to highlight it and press Shift+F9, because the tooltip seems to often fail when an object is Nothing). I would guess that testArray is Nothing when the error occurs. After all, if SendQueue.Count = 0, then testArray won't be set to anything, which means it will be Nothing, which means that the error is coming from testArray.Length. The reason is that if testArray is Nothing, you can't call a property of it, because Nothing has no properties. So you only want that Write statement inside the If block, because there is nothing to write if there is nothing in the queue.