ANSISTRING turn char code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = "Haha"; char * chr = test.c_str ();}
Char turn ANSISTRING code:
#include
Ansistring turn INT code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = "123"; INT I = STRTOINT (TEST);}
INT to ANSISTRING code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {INT i = 123; ANSISTRING STR = INTOSTR (i);
ANSISTING Turn Double Code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = "123"; long double d = strtofloat (TEST);
Double transfer ANSISTRING code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {double d = 123.456; Ansistring str = floattostr (d);
Double transfer Ansistring and rounded
Code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {long double d = 123.456121212; Ansistring str = floattostrf (d, fffiXed, 5, 4); // Description FloatTOSTRF 5 represents from the first few numbers to start 4 represents 4 digits. // Get STR is 123.4600 after execution. : roll:}
Double transfer Ansistring uses a VB's Format function
Code: void __fastcall tform1 :: button1click (TOBJECT * Sender) {double d = 123.456; Ansistring str = formatfloat ("000000.00", d);} // get 000123.45, of course you can use "#.,; E E- XX "Other symbols, you try it yourself: Wink:
ANSI turns Tclor type (from now on Ansisting Ansi) ANSI Code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {Ansistring Test = "0x00FF8080"; tcolor color color (test);}
Tclor to ANSI code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {tcolor col = 0x00FF8080; ANSISTRING STR = ColorToString (color);} ANSI part eliminates, haha, similar to the MID function in VB, but it is anti-code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = "Abcdef"; int first = 3; // Eliminate the beginning of INT length = 2; // Eliminate the length ANSISTRING DSTR = Test.delete (First, Length) } // Get Abef
Part of the ANSI inserts code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = "Abcdef"; Ansistring INS = "12345"; // Insert Skew INT POS = 3; // Where to Insert ISTR = Test.insert (INS, POS ): // Get AB12345CDEF}
Get an ANSI a bit character code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {Ansistring Test = "Abcdef"; Ansistring Npos = TEST [3]; // Get C}
Get the last character code in ANSI:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = "Abcdef"; char * lstr = test.ansilastchar (); // Get f}
Remove the ANSI characters, this is the MID function of VB! Code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = "Abcdef"; int first = 3; // 3 Start Take INT Length = 2; // Take 2 Ansistring Getstr = Test.Substring (First, Length) ; // Get CD}
The ANSI's letter is the same comparison code:
Void __fastcall tform1 :: button1click (TOBJECT * sender) {ansistring test = "abcdef"; Ansistring Sample = "Abcdef"; int result = test.ansicompare (Sample); return 1, different! Size. }
Code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ansistring test = "abcdef"; Ansistring Sample = "Abcdef"; int result = test.ansicompareic (Sample); // Return 0, the same! There is no case in case, haha} looks for character code in ANSI:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {Ansistring test = "abcdef"; ansistring sample = "e"; int result = test.pos (sample); // Return 5, if you write Sample = "Haha", Return 0, can't find it, haha}
Looking for strings in ANSI, and last similar code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {Ansistring test = "abcdef"; ansistring sample = "ef"; int result = test.pos (sample); // Return 5, the position of the E character}
Determine the length of the string, similar to the VB of LEN code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = "Take Gold Currency"; int Len = Test.length (); // Return 8}
Number of strings, similar VB's Left
Code:
Void __fastcall tform1 :: Button1click (TOBJECT * Sender) {ANSISTRING TEST = "Little Apple"; ANSISTRING SLSTR = Test.setlength (6);} // Get "Little Apple"
Detect double-character string code:
Void __fastcall tform1 :: Button1click (TOBJECT * Sender) {ANSISTRING ChKSTR = "Hello"; int CHKPOS = 1; IF (ByType (Chkstr, ChKPOS) == MBSINGLEBYTE) {Edit1-> text = "0";} else { Edit1-> text = "1";} // Return 1, if you write Chkstr = "fxxk", return 0}
Detect empty string code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = ""; BOOL CHK = Test.isempty (); if (chk) Edit1-> text = "1"; // Return 1}
All stools lowercase VS all coverage code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = "AbcDef"; Ansistring Lstr = Test.LowerCase ();} code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = "Abcdef"; Ansistring Ustr = Test.uppercase ();
Similar to VB to demine-free function code:
void __fastcall TForm1 :: Button1Click (TObject * Sender) {AnsiString Test = "ABCDEF"; AnsiString TLstr = Test.TrimLeft (); AnsiString TRstr = Test.TrimRight (); AnsiString Tstr = Test.Trim ();}
However, this processing that does not have a full corner, how to do ni ~ code:
ANSISTRING __FASTCALL TFORM1 :: Trimstr (AnsistringTM, ANSISTRING LR) {// LR ... L: Left Remove R: Right Remove B: Dou Remove INT LEN; // Left Remove IF (LR == "L" || LR == "B") {len = tm.length (); while (tm.substring (1,1) == "" || tm.substring (1, 2) == "") {// half angle remove IF (TM .SUBSTRING (1) == "") {TM = Tm.Substring (2, len); len = tm.length ();} // Remove else if (tm.substring (1, 2) == "") {TM = Tm.Substring (3, len); len = tm.length ();}}} // Right removal IF (lr == "r" || lr == "b") {len = TM.LENGTH (); while (tm.substring (len, 1) == "" || tm.substring (len-1, 2) == "") {// half angle remove IF (TM.SUBSTRING (LEN, 1) == "") {len = tm.length (); tm = tm.substring (1, len-1); len = tm.length ();} // Remove else if (tm.substring) LEN-1, 2) == "" "{len = Tm.Length (); TM = Tm.Substring (1, len-2); len = tm.length ();}}} ReturnTM;}}} ReturnTM;} void __fastcall TFORM1 :: Button1Click (TOBJECT * Sender) {ANSISTRING TEST = "Fighter"; Ansistring Ret = Trimstr (TEST, "B")} True input
Code:
Void __fastcall tform1 :: button1click (TOBJECT * Sender) {Ansistring Soc = Ansistring :: StringOfchar ('*', 100); Edit1-> Text = SOC; // Show 100 *}
String replacement code:
void __fastcall TForm1 :: Button1Click (TObject * Sender) {AnsiString Str = "Borland C Builder is free"; AnsiString From = "C Builder"; AnsiString To = "Delphi"; AnsiString Result; Result = StringReplace (Str, From, To , TreplaceFlags () << RFREPLACEALL << RFIGNORECASE); // << is the parameter, get Borland Delphi is free}
Full-angle half-corner code:
AnsiString Zen = "1234567890"; int Len = Zen.Length (); char buf [MAX_PATH]; ZeroMemory (buf, sizeof (buf)); LCMapString (GetUserDefaultLCID (), LCMAP_HALFWIDTH, Zen.c_str (), Len, buf, SIZEOF (BUF)); ANSISUSTRING HAN = Ansistring (BUF); Edit1-> Text = HAN;
Half-angle all corner code:
void __fastcall TForm1 :: Button1Click (TObject * Sender) {AnsiString Han = "1234567890"; int Len = Han.Length (); char buf [MAX_PATH]; ZeroMemory (buf, sizeof (buf)); LCMapString (GetUserDefaultLCID (), LcMap_FullWidth, han.c_str (), len, buf, sizeof (buf)); ANSISUSTRING ZEN = Ansistring (BUF);