ADO DOT NET Posted March 10, 2007 Posted March 10, 2007 Hi, I want to check if there are 3 underlines (not less, not more) in a string? I know I can use IndexOf, but it will only return the location of first occur. How can I check this in .NET 2? Thanks:) Quote
MrPaul Posted March 10, 2007 Posted March 10, 2007 IndexOf overloads The IndexOf method has overloads which take a starting position, which will allow you to start each search from the position of the previous underscore: Dim count As Integer Dim pos As Integer count = 0 pos = someString.IndexOf("_"c) While (pos > -1) count = count + 1 pos = someString.IndexOf("_"c, pos + 1) End While Good luck :cool: Quote Never trouble another for what you can do for yourself.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.