user3241846
user3241846

Reputation: 677

specify number of digits of Integer using Format VBA

I want to take an integer and display it in digits no matter what the value, e.g Int = 1 to be displayed as 001. No the integer will never be more than 3 digits. Its probably simple and im just missing the obvious.

CStr(Format(Int, 000)

I am concatenating the result as a string. Thanks

Upvotes: 3

Views: 15365

Answers (2)

Wayne G. Dunn
Wayne G. Dunn

Reputation: 4312

This will always show three digits:

MsgBox Format(iMyInt, "000")

Upvotes: 6

Jimmy Smith
Jimmy Smith

Reputation: 2451

I think all you needed was double-quotes:

CStr(Format(Int, "000")

Upvotes: 2

Related Questions