Click here to Skip to main content
12,443,996 members (39,481 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VS2008 Visual-Studio Sorting , +
Hi guyz,

I wrote a tiny programme in VB.NET using VS.NET 2008 to sort numbers.

I take the input of numbers separated by commas from TextBox1.text, play some algorithm then by clicking a button, display the sorted values in TextBox2.text.

NOW i want to restrict the numbers to be only 20 positions (eg. 32,1,6,32,12,21,21,54,675,8,4,3,2,9,0,21,21,21,43,744) in the TextBox1.text and so i thought of counting the commas Laugh | :laugh:

Can I do that, how? OR is there any better way to achieve this?


Thanks
Posted 6-Dec-09 22:00pm
nGrafix184
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

No need to count the commas.
Use Textbox1.Text.Split(',').Length. It gives you the count of the numbers added in the textbox separated by comma.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

You could do it the reqular expression way:
Dim valid AS Boolean = Regex.IsMatch(TextBox1.Text, "^(,?\d+){0,20}$")

This would also validate the input, anything other than numbers or commas would return false.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160811.3 | Last Updated 7 Dec 2009
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100