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 目的是限制用户输入像这样的数据 要格式一样。
...全文
765打赏收藏
急 用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