![]() |
Input box
I have an input box that my users put a number in. The number is then used
throught my macro to identify a file. Eveything works fine until the user enters a number like 089 or 054. If there is a preceeding zero in the number the zero is dropped off and the macro then trys to use 89 or 54 as the inputed nunber. How can I keep the zero? |
Input box
Assign the input as text rather than number.
"hshayh0rn" wrote:. I have an input box that my users put a number in. The number is then used throught my macro to identify a file. Eveything works fine until the user enters a number like 089 or 054. If there is a preceeding zero in the number the zero is dropped off and the macro then trys to use 89 or 54 as the inputed nunber. How can I keep the zero? |
Input box
Hi
You can either force it to a text: '--------------------------------------------------------------------- Sub test() Dim s As String s = Application.InputBox("Enter file number", "File", , , , , , 2) MsgBox s ' add code for case s="False" ie user clicked Cancel End Sub '----------------------------------------------------------------------- or, if numbers are 3-digit long for sure, format explicitely the output (v in thsi exmaple): v=strings.format(v,"000") ' force to 3-digit -- Regards, Sébastien <http://www.ondemandanalysis.com "hshayh0rn" wrote: I have an input box that my users put a number in. The number is then used throught my macro to identify a file. Eveything works fine until the user enters a number like 089 or 054. If there is a preceeding zero in the number the zero is dropped off and the macro then trys to use 89 or 54 as the inputed nunber. How can I keep the zero? |
All times are GMT +1. The time now is 12:38 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com