易截截图软件、单文件、免安装、纯绿色、仅160KB

delphi学习 字符串切割问题(split)

最近做一个项目,要用Delphi,以前从未学过,好是费劲啊,哈哈光是字符串切割这个问题就困扰了几个小时,通过查资料终于解决,在这与大家分享一下
Function split(src: pchar; ch: char):TStringList;
// 分割字符串
var
  i: Integer;
  tmp : string;
begin
  Result:=TStringList.Create;
  tmp := '';
  showmessage(src);
  showmessage(inttostr(Length(src)));
  for i := 0 to Length(src) do
  begin
    if src[i] <> ch then
    begin
      tmp := tmp + src[i];
    end
    else
    begin
      Result.Add(tmp);
      tmp := '';
    end;
  end;   
  Result.Add(tmp);
end;
说明一下,有些人用Pos函数来对字符串分割,这个函数对中文处理不了,所以最好不要用,
调用方法
先定义一个 var AStrings: TStringList;
在下面使用时 AStrings:=TStringList.Create;然后AStrings:=FaClass.split(pchar(AStr),'|');就把分割后的数组保存在了AStrings中了


相关文档:

翻译一半的Delphi汇编帮助

 The built-in assembler allows you to write assembly code within Delphi programs. It has the following features:
内嵌的汇编器允许在delphi程序中书写汇编代码,他有如下特性:
Allows for inline assembly
允许内嵌汇编
    Supports all instructions found in the Intel Pentium III, In ......

delphi发送焦点移动消息的函数及参数


procedure TForm_BaseMDI.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
     begin
     Key := #0;
     SendMessage(Handle, 48384, 9, 0);     
     end;
end; ......

Delphi Excel to Sql Server

 unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ADODB,comobj, OleServer,
  ExcelXP;
type
  TForm1 = class(TForm)
    ADOConn: TADOConnection;
& ......

在Delphi中使用正则表达式

//参考地址:http://www.wangchao.net.cn/bbsdetail_41190.html
一、微软RegExp
      1. 下载并安装最新版的"Microsoft(r) Windows(r) Script"
  2. RegExp包含在vbscript.dll中所以我们必须先注册regsvr32 vbscript.dll
  注(安装了Ie5后默认已经包含该控件)
  3.在Delph ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号