Current location - Quotes Website - Collection of slogans - Why does your own vb program always prompt invalid port numbers?
Why does your own vb program always prompt invalid port numbers?
The reason is: the port cannot be operated when it is not opened, cannot be opened again when it is opened, and cannot be closed again when it is closed.

Solution:

use

exist

mistake

biographical notes

Next, continue running if you encounter an error.

When you want to send data, or in some necessary cases, check.

It's Mscomm 1. PortOpen =True? If not, you can try to open the port once or pop up a prompt dialog box.

For example:

exist

mistake

biographical notes

then

if

Mscomm 1。 Port open

=

wrong

then

MSComm 1。 PortOpen=True

if

MSComm 1。 Port open

=

wrong

then

dialog box

"COM 1 failed to open!"

end

if

It is troublesome to check the port before each operation, but it is very effective.