|
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString stString = "1.000,1.234,5.678,1.100,1.100,1.154,5.660,-1.201,-2.345,";
int i, j, iRow;
iRow = 1;
for(i=0, j=0; i<=stString.Length(); i++)
{
if(stString.IsDelimiter(",", i))
{
StringGrid1->RowCount = iRow + 1;
StringGrid1->Cells[0][iRow] = IntToStr(iRow);
StringGrid1->Cells[1][iRow] = stString.SubString(j+1, i-j-1);
iRow++;
j = i;
}
}
}
//---------------------------------------------------------------------------
즐코딩하세요.. ~~
초보멋진빌더 님이 쓰신 글 :
: 232통신 장비 관련입니다.
: 데이터는 지금 보시는 데로 read data command 를 보내면
: 데이터를 바로 장비에서 긁어 올 수 있습니다.
: 지금 메모장에 서 받고 있는데 한 라인에 8byte 씩 짤려 표기만 되네요..
: 메모장에 이렇게 나타 납니다.
: 1.000,1.
: 234,5.67
: 8,1.100,
: 1.100,1.
: 154,5.66
:
: 이런식으로 "," 기준으로 9개가 나옵니다.
: 이 데이터를 TStringGrid로 옮기려 합니다. 한번만 도와 주세요..
:
: //---------------------------------------------------------------------------
: //******************* Read_Data Command Setting **************************//
: //---------------------------------------------------------------------------
:
: void __fastcall TTform::Button_ReadClick(TObject *Sender)
: {
:
: AnsiString Str_Read;
:
: Str_Read.sprintf("\x02\x44\x03\x42");
: ComPort1-> WriteStr(Str_Read);
: Memo2-> Lines -> Add(" DownLoad Start ");
: }
:
: //---------------------------------------------------------------------------
: //******************* Read Data DownLoad *********************************//
: //---------------------------------------------------------------------------
:
: void __fastcall TTform::ComPort1RxChar(TObject *Sender, int Count)
: {
:
: String stBuffer, stString = "";
: int Read_Count;
: char chByte;
: unsigned char ReceiveBuffer[4096];
:
:
: ComPort1->ReadStr(stBuffer, Count);
:
: for(Read_Count = 0; Read_Count < stBuffer.Length(); Read_Count ++) {
: ReceiveBuffer[Read_Count] = stBuffer.c_str()[Read_Count];
:
: chByte = stBuffer.c_str()[Read_Count];
: stString = stString + chByte;
: }
: Memo1->Lines->Add(stString);
:
: if(Count == 0)
: Memo2 -> Lines-> Add("Buffer Empty");
: if(Count % 9)
: Memo2 -> Lines-> Add("Buffer Error");
: if(Count == 9)
: Memo2 -> Lines-> Add("Read Data DownLoad Success");
:
: }
: //---------------------------------------------------------------------------
|