Click here to Skip to main content
16,023,047 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
VB.NET
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


Regards,
Srikar
Posted
Updated 5-Dec-09 16:35pm
v2

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:
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

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.
 
Share this answer
 
hi,

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.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900