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!

Calculations and leading zero's 1

Status
Not open for further replies.

RnRExpress

Technical User
Oct 24, 2004
53
US
I have this code which I did to convert Callphone ESN's in Hex to Decimal.

Private Sub Hex2Dec_Click()
left2 = Left([Customer ESN Hex], 2)
right6 = Right([Customer ESN Hex], 6)

dleft = "&H" & left2
dright = "&H" & right6

valleft = Val(dleft)
valright = Val(dright)

dec_number = "0" & valleft & valright

Me.[Customer ESN] = dec_number
End Sub

Valright needs to always be 8 digits. But sometimes the calculation results have a leading "0", (i.e. 01234567) When that happens, the dec_number result is off by a number because valright shows 1234567 instead of 01234567.

Is there any way I can set this up so valright always is 8 digits and if the first number is a 0, then it still will display the 0 and not drop it?

Thanks in advance!!
Richard
 
Take a look at the Format function:
Format(SomeNumVar, "00000000")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top