procedure TForm1.Button1Click(Sender: TObject); var mystr : String; i : Integer; begin mystr := 'abcdefg'; for i := 1 to Length(mystr) do begin ShowMessage(mystr[i]); end; end;procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not (Key in ['0'..'9']) then key:=#0;end;procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char); begin if not (Key in ['a'..'z']) then key:=#0;end;
建议不要学 beyondtkl(大龙驹<逝追>) ,徒增出错的机会而已。
楼上的,我不能在KEYPRESS事件里面写,此法不通 谢谢各位 还有没有其他的办法,大大有赏
不在KEYPRESS中写.为什么. 这种不是很好嘛.为什么行不通
1 没什么好办法,循环提取就可以 2 3 case ord(str[i]) of 48..57: 数字 65..90: 小写 97..122: 大写 end
string[i]LowerCase(string[i])>='a' and LowerCase(string[i]<='z')string[i]>='0' string[i]<='9'
比如说str[1];就是第一个.2.可以判断他的ascall,
if (ord(ch)>65) and (ord(ch) < 97) then
小写的也一样.3,同2,只是他们的ascall值不一样而已.
依次取出一个字符,保存入一个数组中。2. if ( a in [a..z]) or (a in [A..Z]) then
begin
end;3. if (a in [0..9]) then
begin
end;
结束条件为 *p (delphi中好像是p^) char ch; while(ch = *p) p++;或者用循环 上限为Length(str);
2. 3. 很简单...
procedure TForm1.Button1Click(Sender: TObject);
var
mystr : String;
i : Integer;
begin
mystr := 'abcdefg';
for i := 1 to Length(mystr) do
begin
ShowMessage(mystr[i]);
end;
end;procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) then
key:=#0;end;procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['a'..'z']) then
key:=#0;end;
谢谢各位
还有没有其他的办法,大大有赏
这种不是很好嘛.为什么行不通
2
3
case ord(str[i]) of
48..57: 数字
65..90: 小写
97..122: 大写
end