主题:帮忙啊 急!!!!!!
串口程序接收数据代码如下:
void __fastcall TForm1::MSComm1Comm(TObject *Sender)
{
//接收数据
OleVariant Re_Buf;
byte ReBuf[256]={'\0'};
int Len=0;
if(MSComm1->CommEvent==comEvReceive)
{
Len=MSComm1->InBufferCount; //接收字符的长度
if(Len>0)
{
Re_Buf=MSComm1->Input;
for(int m=0;m<=Len;m++)
ReBuf[m]=Re_Buf.GetElement(m);//这里出错
}
}
}
只要接收到数据,就出现错误:Project SetAddress.exe raised exception class EVariantInvalidArgError with message 'Invalid argument'. Process stopped.Use Step or Run to continue.
经过反复测试,问题就出在最后一行代码.
请帮忙看看是怎么回事?如果不能解决的话,有没有别的方法取出Re_Buf中的数据?多谢了!!!
void __fastcall TForm1::MSComm1Comm(TObject *Sender)
{
//接收数据
OleVariant Re_Buf;
byte ReBuf[256]={'\0'};
int Len=0;
if(MSComm1->CommEvent==comEvReceive)
{
Len=MSComm1->InBufferCount; //接收字符的长度
if(Len>0)
{
Re_Buf=MSComm1->Input;
for(int m=0;m<=Len;m++)
ReBuf[m]=Re_Buf.GetElement(m);//这里出错
}
}
}
只要接收到数据,就出现错误:Project SetAddress.exe raised exception class EVariantInvalidArgError with message 'Invalid argument'. Process stopped.Use Step or Run to continue.
经过反复测试,问题就出在最后一行代码.
请帮忙看看是怎么回事?如果不能解决的话,有没有别的方法取出Re_Buf中的数据?多谢了!!!