Strip leading zeroes in a text field

This seems so trivial…

In both the following examples the flatfiles input have fields with leading zeroes. ( none to 2 zeroes eg. “0012345” ).

The idea is to get them to a text filed without the zeroes

(“12345”)

Example 1 …fails as noted ******

Dim mgrtempnbr As Double

Dim MgrEN As String

.

.

MgrEN = Trim$(Mid$(XLine,72,7)) ’ load with manager

mgrtempnbr = Cdbl(MgrEN) '****TYPE MISMATCH

MgrEN = Str$(mgrtempnbr)

I have tried this with or without the functions.

Example 2 seems to work…

Dim SaveKey As String

Dim SaveKeyNbr As Double

.

.

SaveKey = Trim$(Mid$(CurLine,1,11)) ’ Employee Number

.

.

’ Drop leading zeroes.

SaveKeyNbr = SaveKey

SaveKey = SaveKeyNbr

Subject: strip leading zeroes in a text field

How about this?

A = “0012345”

while left$(A,1) = “0”

A = mid$(A,2)

wend

after that, A will equal “12345”

Subject: strip leading zeroes in a text field

If there are no characters in the value that comes in, try the following:

strNumber = “0012345”

strNumber = Cstr ( Clng ( sNumber ) )

This will remove all leading 0’s