//积累经验每一天,以后忘记好搜索
void __fastcall TForm2::btn3Click(TObject *Sender)
{
//初始化验证
mmo->SelStart=0;
mmo->SelLength=mmo->Text.Length();
mmo->SelAttributes->Color=clBlack;
String CGh=Edit->Text;
String CGb =CGh.SubString(1,1);
String CGs =CGh.SubString(2,1);
String CGg =CGh.SubString(3,1);
int HH =0;
int Lnum=mmo->Lines->Strings[0].Length()+2;
//HH=Lnum;
String Mtxt = mmo->Text;
for(int i=1;i<=Mtxt.Length();i++)
{
if(i%Lnum<=14)
{
if(Mtxt.SubString(i,1)==CGb)
{
mmo->SelStart=i-1-HH;
mmo->SelLength=1;
mmo->SelAttributes->Color=clRed;
}
}
else if(i%Lnum<=33 && i%Lnum>14)
{
if(Mtxt.SubString(i,1)==CGs)
{
mmo->SelStart=i-1-HH;
mmo->SelLength=1;
mmo->SelAttributes->Color=clRed;
}
}
else //if(i%Lnum<=52 && i%Lnum>33)
{
if(Mtxt.SubString(i,1)==CGg)
{
//ShowMessage(mmo->Text.SubString(i-HH,1)) ;
mmo->SelStart=i-1-HH;
mmo->SelLength=1;
mmo->SelAttributes->Color=clRed;
}
}
//-----每一行,会有换行符占二个字节,原本一行是52+2=54
if(i%Lnum==0)
HH++;
}
//mmo->SelAttributes->Color=clBlack;
}