如何检查文本框中的文本是否包含任何小于或高于字符的字符? [英] How to check if the text on a textbox contains any character less or higher than a character?

查看:88
本文介绍了如何检查文本框中的文本是否包含任何小于或高于字符的字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。

我需要检查文本框是否包含非整数字符。我找到了方法textbox.text.contains,但它没有帮助我,因为我没有看到在ascii中使用字符值的方法。

I need to check if a textbox contains a non integer character. I found the method textbox.text.contains but it doesn't help me because I don't see the way to work with the character's value in ascii.

我的意思是这样的:

if(nameOfTextBox.text.contains(anyCharacterAscii> 57)|| nameOfTextBox.text.contains(anyCharacterAscii< 48){

if (nameOfTextBox.text.contains(anyCharacterAscii>57)||nameOfTextBox.text.contains(anyCharacterAscii<48){

}

我试图将nameOfTextBox.text放入一个字符串中,但我也不能使用ascii。

I tried to put the nameOfTextBox.text into a string, but I can't work with ascii neither.

我知道我的例子是不可能的所以,如果你能帮我解决这个问题,我将不胜感激。

I know my example is not possible so if you can give me a lead to solve this, I would appreciate it.

推荐答案


您好。

Hi.

我需要检查文本框是否包含非整数字符。我找到了方法textbox.text.contains但它对我没有帮助,因为我没有看到在ascii中使用字符值的方法。

I need to check if a textbox contains a non integer character. I found the method textbox.text.contains but it doesn't help me because I don't see the way to work with the character's value in ascii.

我的意思是这样的:

if(nameOfTextBox.text.contains(anyCharacterAscii> 57)|| nameOfTextBox.text.cont ains(anyCharacterAscii< 48){

if (nameOfTextBox.text.contains(anyCharacterAscii>57)||nameOfTextBox.text.contains(anyCharacterAscii<48){

}

我试图将nameOfTextBox.text放入一个字符串中,但我无法使用ascii既不是。

I tried to put the nameOfTextBox.text into a string, but I can't work with ascii neither.

我知道我的例子是不可能的,所以如果你能帮我解决这个问题,我将不胜感激。

I know my example is not possible so if you can give me a lead to solve this, I would appreciate it.


PD:我可以逐个字符地使用子字符串和a来验证它是否不是整数,但我想是的它存在一种更简单的方式。

PD: I could go character by character with substring and a for validating if it's not an integer, but I imagine that it exists an easier way.


这篇关于如何检查文本框中的文本是否包含任何小于或高于字符的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆