Solved

Remove first character in a do while statement

Posted on 2008-10-28
3
1,348 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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