怎样判断一个字符串是由数字组成、大写字符组成还是小写字符组成?(50分)

  • 主题发起人 greenwon
  • 开始时间
G

greenwon

Unregistered / Unconfirmed
GUEST, unregistred user!
用户在编辑框中输入字符后,我要确定用户输入的是数字还是大写字母或是小写字母。
 
try
strtoint(mystr)
showmessage('此乃数字也!')
except
if mystr=uppercase(mystr) then
showmessage('此乃大写字母!')
else
if mystr=ulowercase(mystr) then
showmessage('此乃小写字母!')
else
showmessage('无法识别,可能是混杂型,:(')
end;
 
能判断出这样的字符串'12DEab2a'吗?
 
可以在Edit的KeyPress事件中加入如下代码:
if (Key in ['0'..'9']) then
showmessage('此乃数字也!');
if (Key in ['A'..'Z']) then
showmessage('此乃大写字母!');
if (Key in ['a'..'z']) then
showmessage('此乃小写字母!')
照此,你还可以判别其他字符;
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
987
SUNSTONE的Delphi笔记
S
S
回复
0
查看
805
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
顶部