掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Stringgridで特定データの個数をカウントする方法について (ID:46448)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
相当久しぶりに書き込みます。 あると便利そうなので、それらしいのを作ってみました。 ※何分まだ未熟者ですので、この程度の簡易なものが限界ですが・・・。 count_if_int( StringList; '='or'>'or'<'or'>='or'<='or'<>'の何れかを指定; 比較対象の数字 ):返値(見つかった個数) 使用例:showmessage( count_if_int( st,'<',100 ) ); と言った具合に使います。 function count_if_int(st:tstringlist;s:string;set_no:integer):integer; var i,i1,i2:integer; st1:TStringList; s1:string; function choice_if:string; begin choice_if := ''; if s = '>' then begin if set_no > i2 then begin choice_if := st[i]; end; end else if s = '>=' then begin if set_no >= i2 then begin choice_if := st[i]; end; end else if s = '<' then begin if set_no < i2 then begin choice_if := st[i]; end; end else if s = '<=' then begin if set_no <= i2 then begin choice_if := st[i]; end; end else if s = '=' then begin if set_no = i2 then begin choice_if := st[i]; end; end else if s = '<>' then begin if set_no <> i2 then begin choice_if := st[i]; end; end else begin // end; end; begin st1 := TStringList.Create; st1.Clear; for i := 0 to st.Count -1 do begin i2 := strtoint(st[i]); if '' <> choice_if then st1.Add(s1) end; count_if_int := st1.Count; st1.Free; end; procedure TForm1.Button1Click(Sender: TObject); var st:TStringList; i:integer; begin st := TStringList.Create; st.Text:= memo1.Text; i := count_if_int(st,'=',8); showmessage(inttostr(i)); st.Free; end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.