?
Solved

Remove first character in a do while statement

Posted on 2008-10-28
3
Medium Priority
?
1,351 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

743 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