Solved

Remove first character in a do while statement

Posted on 2008-10-28
3
1,344 Views
Last Modified: 2013-12-17
I have a Do while statement that I can't get to work. What I would like to do is trim the front of a text box.  For example if a user enters "0001" I would like to trim it to "1".  I think I'm using the Remove function wrong because it just goes on continuous loop right now.  Thanks
string Search = Convert.ToString(SearchTextBox.Text);

            do

            {

                Search.Remove(0);

            }

            while (Search.StartsWith("0"));

Open in new window

0
Comment
Question by:deloused
3 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 250 total points
ID: 22826862
string search="000000120";
search = search.TrimStart('0');

Cheers,

Greg
0
 
LVL 20

Expert Comment

by:Juan_Barrera
ID: 22826893
Try this:

string s = SearchTextBox.Text;

        string Search = Convert.ToString(s);

        do

        {

            s = s.Remove(0, 1);

        }

        while (s.StartsWith("0"));

Open in new window

0
 

Author Closing Comment

by:deloused
ID: 31510968
Thanks, worked perfect!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now