Ask Your Question
1

How do I convert an integer type variable to a string with a specified number of leading zeros within a basic macro? [closed]

asked 2013-11-15 06:51:10 +0200

Shane gravatar image

updated 2020-08-10 14:39:39 +0200

Alex Kemp gravatar image

How do I convert an integer type variable to a string with a specified number of leading zeros within a basic macro?

e.g 5 => "0005"

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-08-10 14:39:49.374228

3 Answers

Sort by » oldest newest most voted
1

answered 2013-11-15 13:15:04 +0200

JPL gravatar image
Dim iNumber As Integer, sString As String
      ' Put 10 zeroes if the total length should be = 10
      sString = Right("0000000000" & iNumber, 10)
edit flag offensive delete link more
0

answered 2020-01-19 00:43:30 +0200

EasyTrieve gravatar image

updated 2020-01-19 00:49:34 +0200

For how to write a simple basic macro to do this, please see my answer to this question.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-11-15 06:51:10 +0200

Seen: 1,419 times

Last updated: Jan 19