数值验证 [英] validation for numeric values

查看:57
本文介绍了数值验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



任何人都可以更正以下代码.我正在尝试限制字符串中的数字值.

我遇到以下错误在'='附近的语法不正确".

我是VB .NET的新手.请帮我解决这个问题.

Hi,

Can anybody correct the below code. I am trying to restrict the numeric values in a string.

I am facing the following error "Incorrect syntax near ''=''".

I am new in VB .NET. Please help me to solve this.

If po_Country.cn_name = "" Then
            o_General.lp_AddPipe(ls_ErrMsg)
            ls_ErrMsg = ls_ErrMsg + "Country Name can not be empty."
        ElseIf po_Country.cn_name.Contains("0-9") Then
            o_General.lp_AddPipe(ls_ErrMsg)
            ls_ErrMsg = ls_ErrMsg + "Country name can not contain numeric values."
        End If



问候,
Srikar



Regards,
Srikar

推荐答案

如果双击Visual Studio错误列表中的错误,它将带您到引起错误的确切行.哪些行引起了错误?另外,请更好地格式化您的代码.您可以通过选择代码,然后在编辑问题时单击代码块"按钮来做到这一点.应该看起来像这样:
If you double click on the error in the Visual Studio error list, it will bring you to the exact line that is causing the error. Which of those lines is causing the error? Also, please format your code better. You can do that by selecting your code then clicking the "code block" button when you edit your question. Should look something like this:
If po_Country.cn_name = "" Then
    o_General.lp_AddPipe(ls_ErrMsg)
    ls_ErrMsg = ls_ErrMsg + "Country Name can not be empty."
ElseIf po_Country.cn_name.Contains("0-9") Then
    o_General.lp_AddPipe(ls_ErrMsg)
    ls_ErrMsg = ls_ErrMsg + "Country name can not contain numeric values."
End If


通过键入以下命令使它看起来像这样:


I made it look like that by typing this:

<pre lang="vb">If po_Country.cn_name = "" Then
    o_General.lp_AddPipe(ls_ErrMsg)
    ls_ErrMsg = ls_ErrMsg + "Country Name can not be empty."
ElseIf po_Country.cn_name.Contains("0-9") Then
    o_General.lp_AddPipe(ls_ErrMsg)
    ls_ErrMsg = ls_ErrMsg + "Country name can not contain numeric values."
End If</pre>


结束 我本可以为您做的,但是我宁愿教您如何做,而不是为您做.


I could have done that for you, but I would rather teach you how to do it than do it for you.




我试图找出答案,但是它显示了一些字符串转换错误.

所以我也在尝试通过使用按键事件来进行另一种尝试,但是在
VB .NET我不好.

谁能帮我.


干杯,

Srikar.


i have tried to find out, but its showing some string conversion error.

so i was trying in another way by using key press event also, but in
VB .NET i am not good.

Can any one help me.


Cheers,

Srikar.


发布确切的错误消息及其发生的代码行,以及所使用的每个变量的数据类型.

只是想一想:也许您还没有将一个变量定义为字符串?也许您正在尝试对文本框或其他内容执行字符串操作.
Post the exact error message you are getting and the line of code that it occurs on, as well as the data type of each variable you are using.

Just a thought: perhaps you have not defined one of your variables as a string? Maybe you are attempting to do a string operation on a textbox or something.


这篇关于数值验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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