Remove first character in a do while statement

Posted on 2008-10-28
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);





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

Open in new window

Question by:deloused
LVL 37

Accepted Solution

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


LVL 20

Expert Comment

ID: 22826893
Try this:

string s = SearchTextBox.Text;

        string Search = Convert.ToString(s);



            s = s.Remove(0, 1);


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

Open in new window


Author Closing Comment

ID: 31510968
Thanks, worked perfect!

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Scheduled IIS .Net2 AppPools recycle and SQL connection Hangs 33 90
Replace &lt; with < 14 56
Connection String 16 43
Visual Studio TFS - how do I check in my code? 2 29
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

14 Experts available now in Live!

Get 1:1 Help Now