本文整理汇总了C++中AnsiString::SubString方法的典型用法代码示例。如果您正苦于以下问题:C++ AnsiString::SubString方法的具体用法?C++ AnsiString::SubString怎么用?C++ AnsiString::SubString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnsiString
的用法示例。
在下文中一共展示了AnsiString::SubString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FormShow
//---------------------------------------------------------------------------
void __fastcall TRegisterFormClass::FormShow(TObject *Sender)
{
VM_START_WITHLEVEL(1)
AnsiString HID = MD5(GetHardwareID()).UpperCase();
HIDEdit->Text = HID.SubString(1, 16) + "-" + HID.SubString(17, 16);
VM_END
}
示例2: StringAlign
//разбивает строку на несколько с учётом максимально допустимой ширины
//str - исходная строка
//AlignText - результирующий текст
//Width - максимальная ширина
void CTextAlign::StringAlign ( const AnsiString &str, TStrings *AlignText, int Width )
{
if ( Width <= 0 )
{
AlignText->Add ( str );
return;
}
if ( str.Length() <= Width )
{
AlignText->Add ( str );
return;
}
AnsiString FirstPart = str.SubString ( 1, Width );
AnsiString LastPart = str.SubString ( Width + 1, str.Length() - Width );
int pos = FirstPart.LastDelimiter(" ");
if ( pos == 0 )
{
//если нет пробелов в строке
AlignText->Add ( FirstPart );
StringAlign ( LastPart, AlignText, Width );
}else
{
AlignText->Add ( FirstPart.SubString ( 1, pos ) );
LastPart = FirstPart.SubString ( pos + 1, FirstPart.Length() - pos ) + LastPart;
StringAlign ( LastPart, AlignText, Width );
}
}
示例3: InValidDateTime
bool __fastcall TEntryForm::InValidDateTime(AnsiString label, TEditPlus *edit)
{
AnsiString ud = edit->Text;
int n = ud.Length();
if (n == 14 && strspn(ud.c_str(), "0123456789") == 14)
{
try
{
int year = ud.SubString(1,4).ToInt();
int month = ud.SubString(5,2).ToInt();
int day = ud.SubString(7,2).ToInt();
int hour = ud.SubString(9,2).ToInt();
int min = ud.SubString(11,2).ToInt();
int sec = ud.SubString(13,2).ToInt();
TDateTime d(year, month, day);
TDateTime t(hour, min, sec, 0);
return false;
}
catch (...)
{}
}
AnsiString msg = "The field "+label+" contains the value '"+edit->Text+"'."
+" This is invalid for a non null datetime field.";
Application->MessageBox(msg.c_str(), "Invalid DateTime", ID_OK);
return true;
}
示例4:
//---------------------------------------------------------------------------
double __fastcall CNHB300::GetWeight()
{
char strReceive[300]={0};
AnsiString strMsg;
AnsiString strMsgNew;
if(ReadSizeData(strReceive))
{
AnsiString strMsg=strReceive;
int nPosStart=strMsg.AnsiPos("ST,");
int nPosEnd=strMsg.SubString(nPosStart,15).AnsiPos("g")+nPosStart-1;
if(nPosStart>0 && nPosEnd>0 && (nPosEnd-nPosStart)>5)
{
strMsgNew=strMsg.SubString(nPosEnd-8,8);
if(strMsgNew.AnsiPos("-")>0)
{
strMsgNew=strMsg.SubString(nPosEnd-7,7);
return strMsgNew.ToDouble()*-1.0;
}
else return strMsgNew.ToDouble();
}
else return -999.0;
}
else return -999.0;
}
示例5: if
//---------------------------------------------------------------------------
TStringList* StringToTok2( AnsiString Words,
AnsiString Dlmtr1, AnsiString Dlmtr2 )
{
AnsiString Work = Words.Trim();
int spos;
TStringList *Making = new TStringList;
int spos1 = Work.AnsiPos(Dlmtr1);
int spos2 = Work.AnsiPos(Dlmtr2);
while (spos1 || spos2) {
// int spos = 0;
if (!spos1 && spos2) spos = spos2;
else if (!spos2 && spos1) spos = spos1;
else spos = (spos1 < spos2) ? spos1 : spos2;
Making->Add(Work.SubString( 1, spos-1));
Work = Work.SubString( spos+1, Work.Length() - spos);
Work = Work.Trim();
spos1 = Work.AnsiPos(Dlmtr1);
spos2 = Work.AnsiPos(Dlmtr2);
} // while
if (Work != "")
Making->Add(Work);
return Making;
}
示例6: GetPeriodStr
//---------------------------------------------------------------------------
AnsiString GetPeriodStr(AnsiString Date1Str,AnsiString Date2Str)
{
// Convert date1 yyyy-mm-dd and date2 yyyy-mm-dd to "(September/February) yyyy - (September/February) yyyy"
AnsiString Res="";
try
{
int y1=Date1Str.SubString(7,4).ToInt(),
m1=Date1Str.SubString(4,2).ToInt(),
d1=Date1Str.SubString(1,2).ToInt(),
y2=Date2Str.SubString(7,4).ToInt(),
m2=Date2Str.SubString(4,2).ToInt(),
d2=Date2Str.SubString(1,2).ToInt();
switch (m1)
{
case 2: Res+="Февраль ";break;
case 9: Res+="Сентябрь ";break;
default: Res+="Unsupport ";break;
}
Res+=AnsiString(y1)+"г. -- ";
switch (m2)
{
case 2: Res+="Февраль ";break;
case 9: Res+="Сентябрь ";break;
default: Res+="Unsupport ";break;
}
Res+=AnsiString(y2)+"г.";
return Res;
}
catch(...)
{
Res="Unknown format of date";
return Res;
}
}
示例7: TrataDadosRetorno
//---------------------------------------------------------------------------
void __fastcall TBolBB::TrataDadosRetorno(AnsiString Linha, int Registro, int &RegDet)
{
AnsiString IdLinha;
if(Retorno.CNAB400 == true)//Padrão FEBRABAN/CNAB400
{
IdLinha = Linha.SubString(1,1);
if(IdLinha == "7")
{
IdLinha = "1";
rtNossoNumero[0] = 64;
rtNossoNumero[1]= 17;
rtMesOrigem[0] = 73;
rtAnoOrigem[0] = 75;
rtLancamentoFat[0] = 77;
}
}
else//Padão FEBRABAN/CNAB240
{
IdLinha = Linha.SubString(8,1);
if(IdLinha == "3")//Registro detalhe
{
IdLinha = "1";
}
}
if(IdLinha == "1")//Registro Detalhes - Movimento
{
if(SetVariaveisRetorno(Linha,Registro))
ManutencaoRetorno(Registro);
RegDet++;
}
}
示例8: GetLinhaDigitavel
//---------------------------------------------------------------------------
AnsiString __fastcall TBolBancoob::GetLinhaDigitavel(void)
{
GetNossoNumero();
AnsiString NossoNumeroComDV = NossoNumeroSemHifen;
// Grupo 1
AnsiString Grupo1 = CodigoBanco + CodigoMoeda + Carteira;
Grupo1 = Grupo1 + Agencia + CalculaDVLinhaDigitavel(Grupo1 + Agencia);
// Grupo 2
AnsiString Grupo2 = "02" + CodigoCedente.SubString(1, 3);
AnsiString Parte2 = CodigoCedente.SubString(4, 4) + NossoNumeroComDV.SubString(1, 1);
Grupo2 = Grupo2 + Parte2 + CalculaDVLinhaDigitavel(Grupo2 + Parte2);
// Grupo 3
AnsiString Grupo3 = NossoNumeroComDV.SubString(2, 5) + NossoNumeroComDV.SubString(7, 2);
//Grupo3 = Grupo3 + TipoFaturamento + "01"; Substituído pela próxima Linha
Grupo3 = Grupo3 + "001"; // Conforme Manual Sicoob/SC pág. 6 - Terceiro Grupo de Números - Posição 9
Grupo3 = Grupo3 + CalculaDVLinhaDigitavel(Grupo3);
// Grupo 4
GetCodigoDeBarra(); // pra garantir que calculou o DVCodBarras
AnsiString Grupo4 = DVCodBarras;
// Grupo 5
AnsiString Grupo5 = FatorVencimento + ValorBoleto;
ValidaLinhaDigitavel(Grupo1 + Grupo2 + Grupo3 + Grupo4 + Grupo5);
return ( Grupo1 + Grupo2 + Grupo3 + Grupo4 + Grupo5 );
}
示例9: GetStrWithReplacedPoints
//---------------------------------------------------------------------------
AnsiString GetStrWithReplacedPoints(AnsiString Str, AnsiString PointStr=GetPointStr())
{
AnsiString RetStr;
int posPoint=Str.Pos(",");
if (posPoint>0) RetStr=Str.SubString(1,posPoint-1)+PointStr+Str.SubString(posPoint+1,Str.Length()-posPoint);
posPoint=Str.Pos(".");
if (posPoint>0) RetStr=Str.SubString(1,posPoint-1)+PointStr+Str.SubString(posPoint+1,Str.Length()-posPoint);
return RetStr;
}
示例10: ReturnParsedDateInSQL
//---------------------------------------------------------------------------
AnsiString ReturnParsedDateInSQL(AnsiString Str)
{
// Date in format dd.mm.yyyy convert to yyyy-mm-dd
AnsiString y=Str.SubString(7,4),
m=Str.SubString(4,2),
d=Str.SubString(1,2),
date;
date=y+"-"+m+"-"+d;
return date;
}
示例11: ReturnParsedDateInMask
//---------------------------------------------------------------------------
AnsiString ReturnParsedDateInMask(AnsiString Str)
{
// Date in format yyyy-mm-dd convert to dd.mm.yyyy
AnsiString y=Str.SubString(1,4),
m=Str.SubString(6,2),
d=Str.SubString(9,2),
date;
date=d+"."+m+"."+y;
return date;
}
示例12: GetTCPClientConfigFromStr
void GetTCPClientConfigFromStr(const AnsiString& configure,
AnsiString& ip,
int& port)
{
int splitpos = configure.AnsiPos(",");
if (splitpos > 0) {
ip = configure.SubString(1, splitpos - 1);
port = StrToInt(configure.SubString(splitpos+1, configure.Length()));
}
}
示例13: GetUserName
AnsiString __fastcall TFTPFile::GetUserName(AnsiString ServerString)
{
int pos = ServerString.LowerCase().Pos("ftp://");
if(pos < 1)
return "";
ServerString = ServerString.SubString(pos + 6,ServerString.Length() - pos);
pos = StrLScan(ServerString.c_str(),":");
if(pos < 0)
return "";
return DecryFTPPassword(ServerString.SubString(1,pos));
}
示例14: StringToTokiensA
//---------------------------------------------------------------------------
void StringToTokiensA( AnsiString Words, AnsiString Dlmtr, TStrings *Making )
{
AnsiString Work = Words.Trim();
int spos;
while ((spos = Work.AnsiPos(Dlmtr)) != 0) {
Making->Add(Work.SubString( 1, spos-1));
Work = Work.SubString( spos+1, Work.Length() - spos);
Work = Work.Trim();
} // while
if (Work != "")
Making->Add(Work);
}
示例15: GetDateAsString
//const int max_count_line = 17; // кол-во строк в одном семестре
//const int max_len_title = 35;
//---------------------------------------------------------------------------
AnsiString TFormReportUchebKartStud::GetDateAsString(const AnsiString& str, bool isYear)
{
AnsiString res = "";
res += str.SubString(9,2);
if (res.Length() == 1)
res = "0" + res;
res += " ";
res += MounthNames[(str.SubString(6, 2).ToInt() - 1) % 12] + " ";
res += str.SubString(1, 4);
if (isYear)
res += " г.";
return res;
}