Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Number output

Reply
 
Old 08-28-2008   #1 (permalink)
keith


 
 

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
Old 08-28-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

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
Old 08-28-2008   #3 (permalink)
Richard Mueller [MVP]


 
 

Re: Number output


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

>
> "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
Old 08-28-2008   #4 (permalink)
keith


 
 

Re: Number output

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

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

> > "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.
>
Quote:

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

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

> > Thanks for all the help.
>
Quote:

> > 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
Old 08-29-2008   #5 (permalink)
Dr J R Stockton


 
 

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:
Quote:

>
>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
Reply

Thread Tools


Similar Threads
Thread Forum
Number of "messages" not relating to actual number Live Mail
Enexpected output when using output-csv PowerShell
7z isn't a number PowerShell
No output from write-output PowerShell
mac number Vista hardware & devices


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46