改為前後可以填入值 |
尚未結案
|
20052020
初階會員 發表:121 回覆:79 積分:40 註冊:2005-01-18 發送簡訊給我 |
請問這一段如何改為前後可以填入值
現在只可能填補後面,如果前面空一格就無法填入 procedure TForm1.Button3Click(Sender: TObject);
begin
Database1.Connected := True;
Table1.Close;
Table1.Open;
Table1.First;
while not Table1.Eof do
begin
Table1.Edit;
Table1.FieldByName('S').AsString := Copy(Table1.FieldByName('S').AsString StringOfChar(' ',Table1.FieldByName('S').Size),1,Table1.FieldByName('S').Size);
Table1.Post;
Table1.Next;
end;
Table1.Close;
Database1.Connected := False;
------
Xax |
cashxin2002
版主 發表:231 回覆:2555 積分:1937 註冊:2003-03-28 發送簡訊給我 |
|
20052020
初階會員 發表:121 回覆:79 積分:40 註冊:2005-01-18 發送簡訊給我 |
|
cashxin2002
版主 發表:231 回覆:2555 積分:1937 註冊:2003-03-28 發送簡訊給我 |
|
20052020
初階會員 發表:121 回覆:79 積分:40 註冊:2005-01-18 發送簡訊給我 |
|
cashxin2002
版主 發表:231 回覆:2555 積分:1937 註冊:2003-03-28 發送簡訊給我 |
您好﹗ 呵呵﹐還是不甚了解您的需要﹐提供您幾個函數﹐您自己試看看﹕
Insert(將某個字串插入到另一字串的某個位置) Var S: String; begin S := 'Delphi is the good tools'; Insert('6.0', S, 7); end; //S值為﹕'Delphi6.0 is the good tools' AnsiQuotedStr(在字串前后增加字元) Var S: String; begin S := 'Delphi is the good tools'; Edit1.Text := AnsiQuotedStr(S, '@'); end; //S值為﹕'@Delphi is the good tools@' AnsiExtractQuotedStr(在字串前后各刪除一個字元) Var P: PChar; S: String; begin P := '@Delphi is the good tools '; S := AnsiExtractQuotedStr(P, '@'); end; //S值為﹕'Delphi is the good tools' LeftStr(從字串左邊取出一個長度的字串內容) RightStr(從字串右邊取出一個長度的字串內容) Var S1, S2: String; begin S1 := LeftStr('Delphi is the good tools', 3); S2 := RightStr('Delphi is the good tools', 3); end; //S1值為﹕'Del'﹐S2值為﹕'ood' Mid(從字串的中間取出一個長度的字串內容) Var S: String; begin S := MidStr('Delphi is the good tools', 3, 5); end; //S值為﹕'lphi '================================= 有空來瞅瞅我﹗因為我是您的朋友﹐有您真好﹗ ================================
------
忻晟 |
20052020
初階會員 發表:121 回覆:79 積分:40 註冊:2005-01-18 發送簡訊給我 |
|
cashxin2002
版主 發表:231 回覆:2555 積分:1937 註冊:2003-03-28 發送簡訊給我 |
您好﹗
procedure TForm1.Button1Click(Sender: TObject); Var S: String; begin S := 'Delphi is the good tools'; Edit1.Text := Insert('6.0', S, 7); end;================================= 有空來瞅瞅我﹗因為我是您的朋友﹐有您真好﹗ ================================
------
忻晟 |
20052020
初階會員 發表:121 回覆:79 積分:40 註冊:2005-01-18 發送簡訊給我 |
|
帥氣銀行
一般會員 發表:13 回覆:40 積分:15 註冊:2005-05-31 發送簡訊給我 |
你好
你的問題是不是要在"固定"長度前後加上字元??
若是的話
我有一個函式請參考
function addSpace(tmpStr:String; MaxLength:Integer):String; var i,Inde:Integer; begin result:=''; Inde:=MaxLength - (Length(tmpStr)); for i:= 1 to Inde do begin result:=' ' result; end; result:=result tmpStr; end;其中MaxLength是所要字串的最大長度 你將' '改成你要的應該就可以用了 參考看看 |
cashxin2002
版主 發表:231 回覆:2555 積分:1937 註冊:2003-03-28 發送簡訊給我 |
引言: 紅色部分還是不可以Sorry 是小弟寫錯了﹐應改成如下﹕ procedure TForm1.Button1Click(Sender: TObject); Var S: String; begin S := 'Delphi is the good tools'; Insert('6.0', S, 7); ShowMessage(S); end; //S值為﹕'Delphi6.0 is the good tools'================================= 有空來瞅瞅我﹗因為我是您的朋友﹐有您真好﹗ ================================
------
忻晟 |
20052020
初階會員 發表:121 回覆:79 積分:40 註冊:2005-01-18 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |