ord(ch)>128 是中文
(ord(ch)>=asc('a') and ord(ch)<=asc('z'))
or(ord(ch)>=asc('A') and ord(ch)<=asc('Z'))是英文字符
其它为其他字符
(ord(ch)>=asc('a') and ord(ch)<=asc('z'))
or(ord(ch)>=asc('A') and ord(ch)<=asc('Z'))是英文字符
其它为其他字符
解决方案 »
- ★★☆ 新手delphi多线程第一课,求教多线程刷新ui界面等基础知识,电子书籍上灭有源代码可以看,汗 ☆★★
- RAVE报表:程序中打几份报表出问题.
- 请各位高手给点做题库的思路和方法
- ISAPI形式WebService的严重Bug
- 如何制作带窗体的WEB服务程序
- 怎么判断现在是否已在屏幕保护状态?
- 小问题!谢谢
- DBGrid的当前选中行颜色的问题!!
- 请大家帮助我,在ADOX中如何在客户端增加存储过程!分数不够再加!
- (interbase)用ibx开发程序时,ibtable.recordcount不能返回正确的记录数,为什么?(新手,急急!!)
- 硬盘盘符交叉怎么办?
- 在Delphi中,怎样把一个窗体中的字符串传到另一窗体中的Edit中并显示?
{mbSingleByte 单字母
mbLeadByte 双字节第一位
mbTrailByte 双字节第二位
}if ByteType(sSendText,128)=mbSingleByte then //字母
if sSendText[128]>='0' and <='9' then
if sSendText[128] in ['A'..'Z','a'..'z'] then
if ByteType(sSendText,128)=mbLeadByte then//末尾是否为半个汉字
只能给你一些提示了:1、根据ASCII码数值来进行判断,Ord()函数就可以把字符转换为对应的数值,值33-126为键盘 可使用字符,值127以上的为未知字符,即为汉字。2、利用函数 strtoint(edit1.text)来判断内容是否为数字,如:
try
int1:=strtoint(edit1.text);
except
messagebox()//不是数字。3、bytetype(str:string,index:integer)函数,判断字节数 //具体用法可以看帮助!
如:if bytetype(str,index)=mbleadbyte then //汉字
else if bytetype(str,index)=mbsinglebyte then // 字母。具体你自己想想怎么做吧!
var
I: Integer;
begin
Result := [];
for I := 1 to Length(mStr) do
Include(Result, mStr[I]);
end; { StrToSet }procedure TForm1.Button1Click(Sender: TObject);
var
E: Extended;
I: Integer;
begin
if TryStrToInt(Edit1.Text, I) then
ShowMessage('整数')
else if TryStrToFloat(Edit1.Text, E) then
ShowMessage('浮点数')
else if Length(WideString(Edit1.Text)) <> Length(Edit1.Text) then
ShowMessage('有汉字')
else if StrToSet(Edit1.Text) <= ['a'..'z', 'A'..'Z'] then
ShowMessage('全部是字母')
else ShowMessage('其他情况');
end;