Ansistring uses Daquan

xiaoxiao2021-03-06  14

// Coding by friecin

// Ansistring turn char void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = "Haha"; char * chr = Test.c_str ();}

// char transfer Ansistring #include void __fastcall tform1 :: button1click (TOBJECT * Sender) {ansistring str = "sample"; char chr [max_path]; strcpy (chr, str .c_str ());}

// Bool Transfer Ansistring Void __fastcall tform1 :: Button1click (TOBJECT * Sender) {Ansistring Test = BoolToStr (CheckBox1-> Checked);}

// Ansistring turn BOOL VOID __FASTCALL TFORM1 :: Button1Click (TOBJECT * Sender) {ANSISTRING TEST = "- 1" CheckBox1-> Checked = strobool (test);

// int in = INTOSTRING STR = INTOSTR (i);}

// Ansistring Transfer Double Void __fastcall tform1 :: Button1click (TOBJECT * Sender) {Ansistring Test = "123"; long double d = strtofloat (test);}

// double 转 = = = = =;;;;;;;;;;;;;;;;

// double 转 a a _ _ __fastcall tform1 :: button1click (TOBJECT * Sender) {long double d = 123.456121212; Ansistring str = floattostrf (d, fffiXed, 5, 4); // Description Floattostrf 5 representative from the first The latter one of the numbers started to go all four, and 4 represents 4 digits. // Get STR is 123.4600 after execution. : roll:}

// Double transfer Ansistring uses a VB's Format function 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", you can try: wink: // Ansistring turn Tclor Void __fastcall tform1 :: button1click (TOBJECT * Sender) {Ansistring Test = "0x00FF8080"; tcolor color color color color (StringTocolor) Test);} // tcolor turn Ansistring void __fastcall TFORM1 :: Button1click (Tobject * sender) {tcolor color = 0x00FF8080; ANSISTRING STR = ColorTString (col);}

// Eliminate a part of the string code in Ansistring: void __fastcall tform1 :: button1click (TOBJECT * Sender) {Ansistring test = "abcdef"; int first = 3; // Eliminate the opening INT length = 2; // Eliminate the set length ANSISTRING DSTR = Test.delete (First, Length);} // Get abef

/ / Insert a string void __fastcall tform1 :: button1click (TOBJECT * Sender) {Ansistring Test = "Abcdef"; // Insert INT POS = 3; // Insert ISTR = Test.insert (INS, POS); // Get ab12345cdef}

// get an ANSI a bit Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = "Abcdef"; Ansistring Npos = TEST [3]; // Get C}

// Get the last character void __fastcall tform1 :: button1click (TOBJECT * Sender) {Ansistring Test = "Abcdef"; char * lstr = test.ansilastchar (); // Get f}

// Remove the ANSISTRING character, this similar VB's MID function! 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 a CD} // Ansistring letter comparison VOID __FASTCALL TFORM1 :: Button1Click (TOBJECT * Sender) {Ansistring Test = "Abcdef"; ansistring sample = "abcdef"; int result = test.ansicompare (Sample); // Return 1, different! Size. }

Void __fastcall tform1 :: button1click (TOBJECT * Sender) {ansistring test = "abcdef"; Ansistring Sample = "Abcdef"; int result = test.ansicompareic (Sample); // Return 0, the same! No case in case, haha}

// Look in the character void __fastcall tform1 :: butt = "abcdef"; ansistring sample = "e"; int result = Test.pos (Sample); // Return 5, if you Write Sample = "Haha", return 0, can't find it, haha}

// Find a string in Ansistring, and the last similar void __fastcall tform1 :: button1click (TOBJECT * Sender) {Ansistring test = "abcdef"; ansistring sample = "ef"; int result = test.pos (sample); / / Return 5, that is, the position of the E character}

/ / Judgment the length of the string, similar VB's Len Void __fastcall tform1 :: Button1click (TOBJECT * Sender) {ANSISTRING TEST = "Take Gold Currency"; int Len = Test.length (); // Return 8}

// get a string, similar VB's Left void __fastcall tform1 :: button1click (TOBJECT * Sender) {ANSISTRING TEST = "Little apple"; Ansistring Slstr = Test.setlength (6);} // Get "Small apple"

// Detect double-character string void __fastcall tform1 :: button1click (Tobject * sender) {ANSISTRING ChKSTR = "Hello"; int CHKPOS = 1; if (ByType (Chkstr, Chkpos) == mbsinglebyte) {Edit1-> Text = "0";} else {edit1-> text = "1";} // returns 1, if you write Chkstr = "fxxk", return 0} // Detective Strings Void __fastcall TFORM1 :: Button1click (TOBJECT * Sender) {ANSISTRING TEST = ""; BOOL CHK = Test.isempty (); if (chk) Edit1-> text = "1"; // Return 1}

// All lowercase VS All larger-write 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 ();

Vb // Similar to spaces in the Trim function 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 code: ANSISUSTRING __FASTCALL TFORM1 :: Trimstr (ANSISTRINGTM, ANSISTRING LR) {// lr ... l: Left Remove R: Right Remove B: Dou Remove IF; // Left (LR == "L" || lr == "b") {len = tm.length (); while (tm.substring (1,1) == "|| tm.substring (1, 2) = = "" "{// half angle of IF (TM.SUBSTRING (1, 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.substring (1, len-2); len = tm.ley ( );}}} Return Tm;} void __fastcall tform1 :: button1click (Tobject * sender) {Ansistring test = "fist"; ANSISSIING RET = Trimstr (TEST, "B")}

// Take the same character repeated input void __fastcall tform1 :: button1click (TOBJECT * Sender) {Ansistring Soc = Ansistring :: stringofchar ('*', 100); edit1-> text = SOC; // Show 100 *}

Alternatively string // 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}

// half-width angle becomes full 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); Ansistring Han = Ansistring (BUF); Edit1-> Text = HAN;

// Half-angle all corner 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)); ANSISTRING ZEN = Ansistring (BUF);

转载请注明原文地址:https://www.9cbs.com/read-46295.html

New Post(0)