+ Reply to Thread
Results 1 to 3 of 3

Input box

  1. #1
    hshayh0rn
    Guest

    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?

  2. #2
    Toppers
    Guest

    RE: 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?


  3. #3
    sebastienm
    Guest

    RE: 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?


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1