Substitute old print Using command 
Author Message
 Substitute old print Using command

Would anyone tell me the best way to substitute in VisualBasic old MS-Dos
QuickBasic compiler's command PRINT USING  "####.##" so that all columns
decimal points are on the same vertical line. Manuals "###0.00" doesn't work
properly.

John

--
Jussi N?rhi
Marjatie 12 A 3
90460 Oulunsalo
Gsm 040-7646 147



Thu, 14 Oct 2004 22:46:14 GMT  
 Substitute old print Using command
You can play around with this code sample (which **only** deals with pure numbers). You
would use it like this

     Print NumberUsing(1.23, "#####.##")

Remember, though, the alignment will only work correctly if you use a fixed-width font
(like Courier for example).

Rick

Function NumberUsing(Number As Variant, _
             FormatString As String) As String
  If InStr(FormatString, ".") Then
    NumberUsing = Format$(Number, "0." & _
                           String$(Len(FormatString) - _
                           InStr(FormatString, "."), "0"))
  Else
    NumberUsing = Format$(Number, "0")
  End If
  NumberUsing = Format$(NumberUsing, _

End Function


Quote:
> Would anyone tell me the best way to substitute in VisualBasic old MS-Dos
> QuickBasic compiler's command PRINT USING  "####.##" so that all columns
> decimal points are on the same vertical line. Manuals "###0.00" doesn't work
> properly.

> John

> --
> Jussi N?rhi
> Marjatie 12 A 3
> 90460 Oulunsalo
> Gsm 040-7646 147




Fri, 15 Oct 2004 01:45:37 GMT  
 Substitute old print Using command
You have two problems here

1) Formatting a number to 2 decimal places in a string
2) Displaying those strings in columns

VB has a Format Function - I don't use it - in fact I out-scope it
with my own which I wrote after reading a VAX BASIC manual in about
1988

Fortunately for us numbers are all the same width
- ie: 1 is the same width as 9

So you just need to right justify the numbers when you print them

Me.CurrentX = TabPos - Me.TextWidth( TheFormattedNo$ )
Me.Print TheFormattedNo$

Personally I would box this in a procedure like :-

    LS_Locate V, H
    LS_PrintNo "####.##", TheNumber#

On Sun, 28 Apr 2002 17:46:14 +0300, "Jussi N?rhi"

Quote:

>Would anyone tell me the best way to substitute in VisualBasic old MS-Dos
>QuickBasic compiler's command PRINT USING  "####.##" so that all columns
>decimal points are on the same vertical line. Manuals "###0.00" doesn't work
>properly.

>John

>--
>Jussi N?rhi
>Marjatie 12 A 3
>90460 Oulunsalo
>Gsm 040-7646 147




Fri, 15 Oct 2004 15:31:03 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. What is VB6 substitute for the old Graph control

2. substitute the old MsSanserif by Arial for Visual Basic

3. How to substitute old OLEAUT32.dll ?

4. Old Sleep and old Files commands in VB?

5. substitution for the old PRINT USING

6. Old COMMAND/CMD Commands

7. How to print blanks (or substitute characters) in bar codes with Crystal

8. Using enter as substitute tab

9. Using enter as substitute tab

10. Another substitute for using  ?

11. Print a report using command button on a form

12. Using Print Command

 

 
Powered by phpBB® Forum Software