Link to home
Start Free TrialLog in
Avatar of brgdotnet
brgdotnetFlag for United States of America

asked on

VB.net how to use TrimStart

I have a text box control which accepts numeric numbers as a string. So how can I strip off any leading zeroes before any type of conversion to a numeric?
 if someone enters any of the following for example I need to strip off the leading 00s :
"0056"
"06"

I have tried the following but it is not working:
If txtNumInput.Text.Trim = txtNumInput.Text.Trim.TrimStart('0') ' This wont work

If txtNumInput.Text.Trim = txtNumInput.Text.ToString.Trim.TrimStart('0') ' This also won't work
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brgdotnet

ASKER

Thanks Scott. I actually need to trim the leading zeroes before they are converted to any type of numeric. This has to do with various events on the form I am working with. When an event is triggered the text box must clear the leading zereos. Only when saved to the database is the string converted to numeric. This is the way the architect and BA have specified that it be done. I cannot go rogue and do a premature conversion. So that is why I must trim the zeroes off the string.
Hi Scott, I met with the team and argued for converting to an integer. All is working well. Thanks for your help.