Click here to Skip to main content
14,699,754 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have some numbers like below in textbox

9856321470,1235647809,9847562155,9563256985,8452136547

i need to check that given number between two commas is in 10 digit..
thank you.

means i want to validation that between two commas, the number has 10 digit.
if between two commas number doesn't contain 10 digit the it will give error.
Posted
Updated 20-Feb-14 23:39pm
v2
Comments
   
This post does not even define the problem. What is one number is 10 digit, and another one is not?
More importantly, What have you tried so far?
What is the problem you face here?
—SA
dpokiya 21-Feb-14 4:41am
   
i dont want to split string.
i need validation between two commas that number contains 10 digit.
Tom Marvolo Riddle 21-Feb-14 0:21am
   
sorry not clear.what does it mean?
dpokiya 21-Feb-14 4:42am
   
i dont want to split string.
i need validation between two commas that number contains 10 digit.
Tom Marvolo Riddle 21-Feb-14 4:47am
   
please wait...
Tom Marvolo Riddle 21-Feb-14 5:26am
   
AFAIK you cannot check it without split
dpokiya 21-Feb-14 5:34am
   
ohhhke, you can do with split function
Tom Marvolo Riddle 21-Feb-14 5:27am
   
Is there any reason not to split the string?i'll help you with split function
dpokiya 21-Feb-14 5:36am
   
splitting function i already done. just i need validation for 10 digit.
how can i send image of my snapshot???
Tom Marvolo Riddle 21-Feb-14 5:43am
   
Answer posted.Try it and let me know(Used c# to VB converter)
dpokiya 21-Feb-14 7:05am
   
thank you so much
Tom Marvolo Riddle 21-Feb-14 7:08am
   
you're welcome


[^]
See this link..Sure will help u
If not then ask!
   
Comments
   
Answered, a 5. It's a good idea not to show complete solution, but to help to learn something...
—SA
dpokiya 21-Feb-14 5:20am
   
sir, i need validation weather digit of number between two commas is 10 digit or not.....
dpokiya 21-Feb-14 4:41am
   
i dont want to split string.
i need validation between two commas that number contains 10 digit.
Sergey Alexandrovich Kryukov 21-Feb-14 10:54am
   
No, you need something different: using your own brain, thinking. You go correct answer, now think how to apply it to validation.
Otherwise no solutions could ever help you.
—SA
dpokiya 21-Feb-14 23:47pm
   
ohhhk, yesterday, got the solution
   
Great.
Good luck...
—SA
Tom Marvolo Riddle 22-Feb-14 0:16am
   
Hi Sergey Alexandrovich Kryukov,i just want to know how to do this in another way.sorry,i didn't get another idea.If you know then please explain the logic how to do this.It will help me in future to do this in different way. Thanks and sorry if i said anything wrong.
   
The logic: you split the string by ',' (or any other array of delimiters). It will give you array of string, each representing a slice of your source string. In a loop, for each string of this array, check string.Length == 10.
Is it all clear?
—SA
Tom Marvolo Riddle 22-Feb-14 0:35am
   
Really thanks for the quick reply.but if we get value in string instead of string array then how can we do this.if i understood wrong please explain bit more or post some links regarding this.Sorry i don't know how to ask in english clearly to ask my doubts
   
I don't understand what is your concern. I cannot imagine anything simpler than that. Perhaps, just write it in code; and you will see how it works out.
—SA
Tom Marvolo Riddle 22-Feb-14 0:52am
   
but in this way we have to split the string.am i right?
   
Yes. Why not?
—SA
Tom Marvolo Riddle 22-Feb-14 0:59am
   
Now i understand clearly.Thanks a lot for spending time to clear my doubts.I don't know english well.For me, it takes time to understand what said in engish.once again thanks a lot
   
I must admit your writing English is clear enough and nearly correct.
(Please also take care of your punctuation and capitalization, which is not related to English: not "english well.For me...", but "English well. For me...", not important blank space after '.'. Otherwise it's hard to read.
Good luck.
—SA
Tom Marvolo Riddle 22-Feb-14 1:17am
   
Once again thank you for grooming me
   
You are welcome.
—SA
Try this:
TextBox1.Text = "9856321470,123564780,9847562155,956325698,8452136547"

Dim text As String() = TextBox1.Text.Split(","C)

For i As Integer = 0 To text.Length - 1

	If text(i).Length = 10 Then
			
	ElseIf text(i).Length <> 10 Then
        //error message here
	End If
Next
   
v3
Refer this
String Split
   
Comments
dpokiya 21-Feb-14 4:41am
   
i dont want to split string.
i need validation between two commas that number contains 10 digit.
Sergey Alexandrovich Kryukov 21-Feb-14 10:56am
   
Why would you repeat already existing answer?
—SA

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