Dynamic Split String in VB.net

Posted by Naraayanan under VB.NET on 5/6/2013 | Points: 10 | Views : 1487 | Status : [Member] | Replies : 2
Hi all,
How to Split a Character from String in Vb.Net?I need a function for this below example in the Vb.Net

Here is a Example:

My string format is like this CP00001. here string has mixing of Character and Number. So I want to Increase the value of Number like(2,3,4,....).
How can i achieve this Task.
Note: we don't know the Character.

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/



Responses

Posted by: Niladri.Biswas on: 5/6/2013 [Member] Platinum | Points: 25

Up
0
Down
Hi,
I am providing it is C# as I don;t have VB complier

string source = "CP00001";

string onlyNumeric = Regex.Replace(source, @"[^\d]", ""); //00001
string onlyLetters = Regex.Replace(source, @"[^A-Z]+", String.Empty); //CP


As you can make out that we now have the numeric values and characters. You can now add numbers to it after a proper conversion. A VB.net corresponding code should not be difficult to do.I just used an online covnversion tool (http://www.developerfusion.com/tools/convert/csharp-to-vb/) and here is the result

Dim source As String = "CP00001"

Dim onlyNumeric As String = Regex.Replace(source, "[^\d]", "")
Dim onlyLetters As String = Regex.Replace(source, "[^A-Z]+", [String].Empty)


Hope you got the idea and can now proceed.

Thanks

Best Regards,
Niladri Biswas

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 5/6/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,
Thanks for your reply.

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response