Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trim leading 0's

Status
Not open for further replies.

starmistress

IS-IT--Management
Apr 16, 2001
32
US
Is there a simple VB6 function that will trim leading zero's in a file name? I can think of a long way using Right, Left, Len, and positional type things, but I was hoping not to need to do that. Is there not a function that I am unaware of that will remover leading zero's?
 
Make your own.
Function LTrimZero (byval strIn as string) a string
Dim I as long
For I = 1 to Len(strIN)
if Mid$(strIn,I,1) <> &quot;0&quot; then exit for
Next
LTrimZero = Mid$(strIn,I) ' Returns &quot;&quot; if all &quot;0&quot;
End Function Compare Code (Text)
Generate Sort in VB or VBScript
 
Hoe about

text1 = replace(text1,&quot;0&quot;,&quot;&quot;)

David Paulson

 
[tt]
while instr(instrrev(s, &quot;\&quot;), s, &quot;\0&quot;)
s = replace(s, &quot;\0&quot;, &quot;\&quot;, instrrev(s, &quot;\&quot;))
wend
If InStrRev(s, &quot;\.&quot;) = InStrRev(s, &quot;\&quot;) Then MsgBox &quot;Bad File Name &quot; & s
[/tt]
You might want to clean up by storing InStrRev(s, &quot;\&quot;) in an integer...

Wil Mead
wmead@optonline.net

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top