欢迎来到天天文库
浏览记录
ID:31321348
大小:38.50 KB
页数:8页
时间:2019-01-08
《ansistring使用[大全]》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、word格式精心整理版AnsiString使用大全:顾名思义,就是利用AnsiString来处理相关的各种问题。来看看吧,一定让你受益匪浅! //Ansistring转charvoid__fastcallTForm1::Button1Click(TObject*Sender){ AnsiStringTest="哈哈"; char*chr=Test.c_str();} //char转Ansistring#includevoid__fastcallTForm1::Button1Click(TObject*Sender){ AnsiStringstr="Samp
2、le"; charchr[MAX_PATH]; strcpy(chr,str.c_str());} //Bool转AnsiStringvoid__fastcallTForm1::Button1Click(TObject*Sender){AnsiStringTest=BoolToStr(CheckBox1->Checked);} //Ansistring转boolvoid__fastcallTForm1::Button1Click(TObject*Sender){AnsiStringTest="-1" CheckBox1->Checked=StrToBool(Te
3、st);} //int转ansistringvoid__fastcallTForm1::Button1Click(TObject*Sender){ inti=123; AnsiStringstr=IntToStr(i);} //AnsiString转double范文范例学习指导word格式精心整理版void__fastcallTForm1::Button1Click(TObject*Sender){ AnsiStringTest="123"; longdoubled=StrToFloat(Test);} //double转AnsiStringvoid__fa
4、stcallTForm1::Button1Click(TObject*Sender){ doubled=123.456; AnsiStringstr=FloatToStr(d);} //double转AnsiString并四舍五入void__fastcallTForm1::Button1Click(TObject*Sender){ longdoubled=123.456121212; AnsiStringstr=FloatToStrF(d,ffFixed,5,4);//说明FloatTostrF里5代表从第几个数字的后一位开始四舍五入,4代表取4位小数。//
5、执行后得到str是123.4600。:roll: }//double转AnsiString使用类似vb的format函数void__fastcallTForm1::Button1Click(TObject*Sender){ doubled=123.456; AnsiStringstr=FormatFloat("000000.00",d);}//得到000123.45,当然你能使用"#.,;E+E-xx"等符号,你自己试试:wink: //AnsiString转Tclor型void__fastcallTForm1::Button1Click(TObject*Sen
6、der){ AnsiStringTest="0x00FF8080"; TColorCol=StringToColor(Test);}//Tcolor转AnsiStringvoid__fastcallTForm1::Button1Click(TObject*Sender){ TColorCol=0x00FF8080;范文范例学习指导word格式精心整理版 AnsiStringstr=ColorToString(Col);}//消除AnsiString中的一部分字符串代码:void__fastcallTForm1::Button1Click(TObject*Se
7、nder){ AnsiStringTest="ABCDEF"; intFirst=3; //消除制定开头 intLength=2; //消除制定长度 AnsiStringDstr=Test.Delete(First,Length);}//得到ABEF //在AnsiString中插入字符串void__fastcallTForm1::Button1Click(TObject*Sender){ AnsiStringTest="ABCDEF"; AnsiStringIns="12345"
此文档下载收益归作者所有