C++Builder6控件 - 图文(8)

2019-04-15 16:36

两个字符串相到比较,返回比较的结果,函数原型如下: int __fastcall StrComp(const char * Str1, const char * Str2);

16.StrIComp

两个字符串相互比较(不论大小写),返回比较的结果,函数原型如下: int __fastcall StrIComp(const char * Str1, const char * Str2);

17.StrLComp

对两个字符串指定数目的字符进行比较操作,函数原型如下:

int __fastcall StrLComp(const char * Str1, const char * Str2, Cardinal MaxLen);

18.StrScan

在指定的字符串中寻找特定的字符,并返回字符串中第一个特定字符的指针,函数原型如下:

char * __fastcall StrScan(const char * Str, char Chr);

19.StrRScan

在指定的字符串中寻找特定的字符,并返回字符串中最后一个特定字符的指针,函数原型如下: [NextPage]

char * __fastcall StrRScan(const char * Str, char Chr);

20.StrPos

在Strl所指定的字符串中寻找Str2所指定的子字符串,并返回Str2在Str2中第一个子字符的指针,函数原型如下:

char * __fastcall StrPos(const char * Str1, const char * Str2);

21.StrUpper

将字符串转换为大写形式,函数原型如下: char * __fastcall StrUpper(char * Str);

22.StrLower

将字符串转换为小写形式,函数原型如下: char * __fastcall StrLower(char * Str);

23.StrPas

将指定的字符串转换为AnsiString类型字符串对象,函数原型如下: AnsiString __fastcall StrPas(const char * Str); [Page]

24.StrAlloc

为字符串分配指定字节的内存,并返回内存指针,函数原型如下: char * __fastcall StrAlloc(Cardinal Size);

25.StrBufSize

返回*Str所指向内存的大小,函数原型如下: Cardinal __fastcall StrBufSize(const char * Str);

26.StrNew

在堆中为指定字符串分配空间,并将字符串拷贝到此空间中,函数原型如下: char * __fastcall StrNew(const char * Str); 五.Borland C++ Builder VCL的数值转换函数

1. IntToStr

将整数转换为AnsiString字符串,函数原型如下: AnsiString __fastcall IntToStr(int Value);

2. IntToHex

将整数转换为十六进制字符串,函数原型如下: AnsiString __fastcall IntToHex(int Value, int Digits);

3. StrToInt

将AnsiString字符串转换为整数值,如果不能进行转换,则产生EConvertError异常, 函数原型如下:

int __fastcall StrToInt(const AnsiString S);

4. StrToIntDef

将AnsiString字符串转换为一个数值,函数原型如下:

int __fastcall StrToIntDef(const System::AnsiString S,int Default);

5. FloatToStr

将浮点数转换为AnsiString字符串,函数原型如下: AnsiString __fastcall FloatToStr(Extended Value);

6. StrToFloat

将AnsiString字符串转换为一个浮点数值,函数原型如下: Extended __fastcall StrToFloat(const AnsiString S);

7. FloatToStrF

将浮点数转换为指定格式的AnsiString字符串,函数原型如下:

AnsiString __fastcall FloatToStrF(Extended Value, TFloatFormat Format,int Precision, int Digits);

六.Borland C++ Builder VCL的时间函数

1. Date

返回TDateTime对象,包含当前的年月日信息,函数原型如下: System::TDateTime __fastcall Date(void);

2. Time

返回TDateTime对象,包含当前的时间信息,函数原型如下: System::TDateTime __fastcall Time(void);

3. Now

返回TDateTime对象,获取当前的日期和时间信息,函数原型如下: System::TDateTime __fastcall Now(void);

4. DatetimeToString

将TDateTime对象转换为指定格式的字符串对象,函数原型如下: void __fastcall DateTimeToString(AnsiString &;

Result, const AnsiString Format,System::TDateTime DateTime);

5. DateToStr

将TDateTime对象(包含当前年月日信息)转换为字符串对象,函数原型如下: AnsiString __fastcall DateToStr(System::TDateTime Date); [Page]

6. TimeToStr

将当前日期转换为字符串对象,函数原型如下:

AnsiString __fastcall TimeToStr(System::TDateTime Time);

7. DateTimetoStr

将TDateTime对象转换为字符串对象,函数原型如下:

AnsiString __fastcall DateTimeToStr(System::TDateTime DateTime);

8. StrToDate

将字符串对象转换为年月日对象,函数原型如下:

System::TDateTime __fastcall StrToDate(const AnsiString S);

9. StrToTime

将字符串对象转换时间对象,函数原型如下:

System::TDateTime __fastcall StrToTime(const AnsiString S);

10.StrToDateTime

将字符串对象转换为年月日时间对象,函数原型如下:

System::TDateTime __fastcall StrToDateTime(const AnsiString S);

11.DateTimeToSystemTime

将TDateTime对象转换为操作系统时间,函数原型如下: void __fastcall DateTimeToSystemTime(System::TDateTime DateTime, _SYSTEMTIME &;SystemTime);

12.SystemTimeToDateTime

将操作系统时间转换为TDateTime对象,函数原型如下:

System::TDateTime __fastcall SystemTimeToDateTime(const _SYSTEMTIME &;SystemTime);

怎样用C++Builder存取Excel

---- C++Builder是Borland公司继Delphi之后又一成功的产品,她集VB、VC++ 及 Delphi 的优点于一体而深得C语言爱好者的青睐。由于多数操作者爱用 MicroSoft公司的Excel组织数据,为此本文介绍了用C++Builder存取Excel 文件的两种方法。

---- 一.用OLE技术操纵Excel

---- OLE(对象链接与嵌入)是微软提出的标准,是应用程序间交换数据、相互操作的一种方式,MS OFFICE 提供了很强的 OLE 服务功能,VB、Delphi 及C++Builder等语言都可以以客户方式向Excel提交命令,以存取其数据,其中VB和Delphi最为简单,在语法上就采用类VBA的语句,本报九九年第48期的《在Delphi中操作Excel》一文曾介绍了Delphi的做法。我们原以为C++Builder照搬Delphi,结果语法编译都未能通过,查不到这方面具体介绍的资料。经反复试验方知:原来C++Builder采用间接的办法,利用变体类Variant所提供的四个“方法”向OLE服务程序提交操纵命令:

Variant Variant::OlePropertyGet(属性名,参数….); // 取对象属性

Void Variant::OlePropertySet(属性名,参数….); // 设置对象属性

Variant Variant::OleFunction(函数名,参数….);

// 运行对象的函数

void Variant::OleProcedure(过程名,参数….); // 运行对象的过程

其头文件“vcl\%utilcls.h”必须嵌在用户程序中,

对于这四个长长的方法名可在程序中用宏语句重新定义一下: #define PG OlePropertyGet #define PS OlePropertySet #define FN OleFunction #define PR OleProcedure

例如对于VB的提交语句:

Ex.ActiveWorkBook.ActiveSheet.Cells(1,2).Value=3

为便于理解在C++Builder对应的语句可分解为如下四句: Variant t1=Ex.OlePropertyGet(\ Variant t2=t1.OlePropertyGet(\ Variant t3=t2.OlePropertyGet(\ t3.OlePropertySet(\可去掉中间变量将这四句合为一句,就是: Ex.PG(\

PG(\

我们将下面的VB程序片段改成对应的C++Builder程序以供参考: Private Sub Command1_Click() ' Visual Basic程序片段 Dim Ex As Object,Wb As Object, Sh1 As Object Set Ex = CreateObject(\ Ex.WorkBooks.Open(\ Set Wb = Ex.Activeworkbook Set Sh1 = Wb.ActiveSheet

Text1.Text = Sh1.Cells(1, 1).Value For i = 1 To 10: For j = 1 To 10 Sh1.Cells(i, j).Value = i * 100 + j Next j: Next i

Wb.save: Wb.Close: Ex.Quit

End Sub ' - - - - - -- - - - - - - - - - -

#include \C++Builder程序片段 #include \实用类说明 // …省写此处原一段代码

// 请在此处插入上面提及的四个宏定义语句

void __fastcall TForm1::Button1Click(TObject *Sender) { Variant Ex,Wb,Sh1;

Ex=Variant::CreateObject(\Excel.Application\ Ex.PG(\

Wb=Ex.PG(\


C++Builder6控件 - 图文(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:新人教版二年级下册数学第二单元《表内除法(一)》教材分析及教案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: