vc++6.0 串口编译链接通过之后,运行出错。

vc++6.0 CSerialPort类实现串口编程,编译链接通过后,运行出错,如下。大神帮帮忙!

出错信息

Microsoft Visual C++ Runtime Library

Assertion failed!

Program: ...c++6.0\SerialPortTest\Debug\SerialPortTest.exe
File: C:\Users\zy\Documents\vc++6.0\SerialPortTes...
Line: 112

Expression: portnr > 0 && portnr < 200

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts

(Press Retry to debug the application - JIT must be enabled)

中止(A) 重试(R) 忽略(I)

图片说明

你的portnr值不在合法范围内

串口的端口必须介于1~199之间,而且一般来说,常用的也就是com1~com8。估计你没有初始化portnr。