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 - Format numbers...

Reply
 
Old 10-22-2008   #1 (permalink)
Henrique


 
 

Format numbers...

Hi


Do Until objRecordSet.EOF
GuyFile.Write (objRecordSet.Fields(0).Value)
GuyFile.Write (" ")
GuyFile.Write (objRecordSet.Fields(1).Value)
GuyFile.Write (" ")
GuyFile.Write (objRecordSet.Fields(2).Value)
GuyFile.Write (" ")
GuyFile.Write (objRecordSet.Fields(3).Value)
GuyFile.Write (" ")
GuyFile.Writeline (objRecordSet.Fields(4).Value)

objRecordSet.MoveNext
Loop

With this code the result is:

722 45 127
45 67 985
13 1432 67

And i need:

722 45 127
45 67 985
13 1432 67

Is possible to format the number and write correct?

Thenkyou ins advance

H.




My System SpecsSystem Spec
Old 10-22-2008   #2 (permalink)
ekkehard.horner


 
 

Re: Format numbers...

Henrique schrieb:
Quote:

> Hi
>
>
> Do Until objRecordSet.EOF
> GuyFile.Write (objRecordSet.Fields(0).Value)
> GuyFile.Write (" ")
> GuyFile.Write (objRecordSet.Fields(1).Value)
> GuyFile.Write (" ")
> GuyFile.Write (objRecordSet.Fields(2).Value)
> GuyFile.Write (" ")
> GuyFile.Write (objRecordSet.Fields(3).Value)
> GuyFile.Write (" ")
> GuyFile.Writeline (objRecordSet.Fields(4).Value)
>
> objRecordSet.MoveNext
> Loop
>
> With this code the result is:
>
> 722 45 127
> 45 67 985
> 13 1432 67
>
> And i need:
>
> 722 45 127
> 45 67 985
> 13 1432 67
>
> Is possible to format the number and write correct?
[...]
I'm not sure about your sample/desired output, but maybe this
Quote:
Quote:

>> Const cnMxL = 10
>> WScript.Echo Right( Space( cnMxL ) & 1234567890, cnMxL )
>> WScript.Echo Right( Space( cnMxL ) & 1, cnMxL )
>> WScript.Echo Right( Space( cnMxL ) & 12, cnMxL )
>>
1234567890
1
12

will get you started.
My System SpecsSystem Spec
Old 10-22-2008   #3 (permalink)
Dr J R Stockton


 
 

Re: Format numbers...

In microsoft.public.scripting.vbscript message <48ff0b89$0$14062$9b4e6d9
3@xxxxxx-online.net>, Wed, 22 Oct 2008 13:16:26,
ekkehard.horner <ekkehard.horner@xxxxxx> posted:
Quote:

>
>I'm not sure about your sample/desired output, but maybe this
>
Quote:
Quote:

>>> Const cnMxL = 10
>>> WScript.Echo Right( Space( cnMxL ) & 1234567890, cnMxL )
>>> WScript.Echo Right( Space( cnMxL ) & 1, cnMxL )
>>> WScript.Echo Right( Space( cnMxL ) & 12, cnMxL )
I'd prefer to use a function, something like

function Widen(X, L)
Widen = Space(L-Len(X)) & X
end function

but it needs adjustment if it is to handle "insufficient room" better.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE7 FF2 Op9 Sf3
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
My System SpecsSystem Spec
Old 10-22-2008   #4 (permalink)
Python


 
 

Re: Format numbers...

I generally include a Pad function which looks like

Function Pad ( num , width )
Pad = Right(Space(width)&num,width)
End Function

Then when you want to print the numbers you can specify the field width

Do Until objRecordSet.EOF
for i = 0 to 4
GuyFile.Write Pad(objRecordSet.Fields(i).Value,6)
next
GuyFile.WriteLine
objRecordSet.MoveNext
Loop


My System SpecsSystem Spec
Old 10-23-2008   #5 (permalink)
Henrique


 
 

Re: Format numbers...

Thanks For all



"Henrique" <wq@xxxxxx> escreveu na mensagem
news:newscache$rtt49k$i8e$1@xxxxxx
Quote:

> Hi
>
>
> Do Until objRecordSet.EOF
> GuyFile.Write (objRecordSet.Fields(0).Value)
> GuyFile.Write (" ")
> GuyFile.Write (objRecordSet.Fields(1).Value)
> GuyFile.Write (" ")
> GuyFile.Write (objRecordSet.Fields(2).Value)
> GuyFile.Write (" ")
> GuyFile.Write (objRecordSet.Fields(3).Value)
> GuyFile.Write (" ")
> GuyFile.Writeline (objRecordSet.Fields(4).Value)
>
> objRecordSet.MoveNext
> Loop
>
> With this code the result is:
>
> 722 45 127
> 45 67 985
> 13 1432 67
>
> And i need:
>
> 722 45 127
> 45 67 985
> 13 1432 67
>
> Is possible to format the number and write correct?
>
> Thenkyou ins advance
>
> H.
>
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
convert fax numbers to canonical format Vista print fax & scan
-f format Format-Table Format-List against Select PowerShell
Windows Mail format bar doesn't format color, size, justification Browsers & Mail
Converting date time format to string format PowerShell
Help! DVD format error: "Windows was unable to complete the format Vista General


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