急 用Delphi怎么比较特定位置的字符
用Delphi怎么比较特定位置的字符if (length(edFrom.text)=17 and copy(edFrom.Text,3,1):='-' and copy(edFrom.Text,10,1):='-' and copy(edFrom.Text,14,1):='-'then
20-008147-000-AED 目的是限制用户输入像这样的数据 要格式一样。 --------------------编程问答-------------------- 1.各and间的比较内容,必须要用括号;2.if语句中不能用赋值:=。
正确的语句应是:
if ((length(edFrom.text)=17) and (copy(edFrom.Text,3,1)='-') and (copy(edFrom.Text,10,1)='-') and (copy(edFrom.Text,14,1)='-') then --------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- 给你个例子
procedure TForm1.Button3Click(Sender: TObject);
var
Str:String;
ResultList:TStringList;
I:Integer;
begin
str:= '南京~信息~工程~大学';
ResultList := TStringList.Create;
try
ResultList.Delimiter := '~';
ResultList.DelimitedText := str;
for I:= 0 to ResultList.Count-1 do
begin
Memo1.Lines.Add(ResultList.Strings[I]);
end;
finally
FreeAndNil(ResultList);
end;
end;
只需要判断ResultList的count和字符串的长度就可以了 --------------------编程问答--------------------
补充:.NET技术 , 其他语言