Windows Vista Forums

Number output
  1. #1


    keith Guest

    Number output

    I wrote a script that gets a computer's site name and creates a group
    with that name and a number at the end. There will never be more than
    600 groups with the same site name. That’s three places to the left
    of the decimal. I would like there to be four places to the left of
    the decimal just in case.



    The naming convention for my groups will be [Group X]-0001.

    Whenever I start to add numbers I cant seem to get an output 4 places
    to the left of the decimal. How would I go about doing this?

    Thanks for all the help.

    Keith



      My System SpecsSystem Spec

  2. #2


    Pegasus \(MVP\) Guest

    Re: Number output


    "keith" <keithlr2@xxxxxx> wrote in message
    news:5c971a32-8724-4170-b2ac-f3768771abd0@xxxxxx
    I wrote a script that gets a computer's site name and creates a group
    with that name and a number at the end. There will never be more than
    600 groups with the same site name. That’s three places to the left
    of the decimal. I would like there to be four places to the left of
    the decimal just in case.

    The naming convention for my groups will be [Group X]-0001.

    Whenever I start to add numbers I cant seem to get an output 4 places
    to the left of the decimal. How would I go about doing this?

    Thanks for all the help.

    Keith
    ========
    Try this:
    iNumber = 67
    sGroup = "[Group X]-" & right("000" & iNumber, 5)



      My System SpecsSystem Spec

  3. #3


    Richard Mueller [MVP] Guest

    Re: Number output


    "Pegasus (MVP)" <I.can@xxxxxx> wrote in message
    news:%23O2AuJUCJHA.4176@xxxxxx

    >
    > "keith" <keithlr2@xxxxxx> wrote in message
    > news:5c971a32-8724-4170-b2ac-f3768771abd0@xxxxxx
    > I wrote a script that gets a computer's site name and creates a group
    > with that name and a number at the end. There will never be more than
    > 600 groups with the same site name. That’s three places to the left
    > of the decimal. I would like there to be four places to the left of
    > the decimal just in case.
    >
    > The naming convention for my groups will be [Group X]-0001.
    >
    > Whenever I start to add numbers I cant seem to get an output 4 places
    > to the left of the decimal. How would I go about doing this?
    >
    > Thanks for all the help.
    >
    > Keith
    > ========
    > Try this:
    > iNumber = 67
    > sGroup = "[Group X]-" & right("000" & iNumber, 5)
    >
    >
    Shouldn't it be:

    sGroup = "[Group X]-" & Right("0000" & iNumber, 4)

    This should work for iNumber from 0 to 9999.

    --
    Richard Mueller
    MVP Directory Services
    Hilltop Lab - http://www.rlmueller.net
    --



      My System SpecsSystem Spec

  4. #4


    keith Guest

    Re: Number output

    On Aug 28, 3:47*pm, "Richard Mueller [MVP]" <rlmueller-
    nos...@xxxxxx> wrote:

    > "Pegasus (MVP)" <I....@xxxxxx> wrote in message
    >
    > news:%23O2AuJUCJHA.4176@xxxxxx
    >
    >
    >
    >
    >
    >
    >

    > > "keith" <keith...@xxxxxx> wrote in message
    > >news:5c971a32-8724-4170-b2ac-f3768771abd0@xxxxxx
    > > I wrote a script that gets a computer's site name and creates a group
    > > with that name and a number at the end. *There will never be more than
    > > 600 groups with the same site name. *That’s three places to the left
    > > of the decimal. *I would like there to be four places to the left of
    > > the decimal just in case.
    >

    > > The naming convention for my groups will be [Group X]-0001.
    >

    > > Whenever I start to add numbers I cant seem to get an output 4 places
    > > to the left of the decimal. *How would I go about doing this?
    >

    > > Thanks for all the help.
    >

    > > Keith
    > > ========
    > > Try this:
    > > iNumber = 67
    > > sGroup = "[Group X]-" & right("000" & iNumber, 5)
    >
    > Shouldn't it be:
    >
    > sGroup = "[Group X]-" & Right("0000" & iNumber, 4)
    >
    > This should work for iNumber from 0 to 9999.
    >
    > --
    > Richard Mueller
    > MVP Directory Services
    > Hilltop Lab -http://www.rlmueller.net
    > --- Hide quoted text -
    >
    > - Show quoted text -
    Thank you both for all the help. It worked great.

      My System SpecsSystem Spec

  5. #5


    Dr J R Stockton Guest

    Re: Number output

    In microsoft.public.scripting.vbscript message <e5UZcbUCJHA.2480@xxxxxx
    NGP02.phx.gbl>, Thu, 28 Aug 2008 14:47:06, "Richard Mueller [MVP]"
    <rlmueller-nospam@xxxxxx> posted:

    >
    >Shouldn't it be:
    >
    >sGroup = "[Group X]-" & Right("0000" & iNumber, 4)
    >
    >This should work for iNumber from 0 to 9999.
    Re "shouldn't" : not necessarily. An alternative is

    sGroup = "[Group X]-" & Right(10000 + iNumber, 4)

    which is one character shorter and might be marginally faster

    --
    (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
    Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
    Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
    Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)

      My System SpecsSystem Spec

Number output problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: i need id number Peter Foldes Vista mail 0 29 Sep 2009
Number of "messages" not relating to actual number Buzz Live Mail 18 04 May 2009
Enexpected output when using output-csv ken444444 PowerShell 0 03 Sep 2008
Number pad BarryH Vista hardware & devices 0 04 Oct 2007
No output from write-output DouglasWoods PowerShell 3 13 Apr 2007