OVH Cloud OVH Cloud

aligner des chiffres a l'impression

6 réponses
Avatar
dav
j'imprime une liste de chiffres comme ceci :

dim a, b, c , d as long
a = 10500
b= 50
c = 1250
d = 152030

printer.print
printer.print tab(30) ;a
printer.print tab(30) ;b
printer.print tab(30) ;c
printer.print tab(30) ;d
printer.EndDoc

comment procéder pour faire en sorte que ces chiffres soient alignés a
l'impression.
merci,
dav

6 réponses

Avatar
geo
dav a écrit:
j'imprime une liste de chiffres comme ceci :

dim a, b, c , d as long
a = 10500
b= 50
c = 1250
d = 152030

printer.print
printer.print tab(30) ;a
printer.print tab(30) ;b
printer.print tab(30) ;c
printer.print tab(30) ;d
printer.EndDoc

comment procéder pour faire en sorte que ces chiffres soient alignés a
l'impression.
merci,
dav



mettre des " " (espaces) avant ?
dim i, j , k as integer
j = 10 ' nombre max de chiffres
i = len(a) ' le nombre de chiffre
k = j - i ' le nombre de ' ' a rajouter
a = space(k) & a ' former la sortie definitive

c'est une idee , mais si tu devais l'exploiter , tu devrais la passer
dans une fonction type :
mettre_espace (byval a as string, optional max as integer)

Géo
Avatar
Bonjour,

Personnellement, j'utilise la méthode suivante :

Dim Align as long

Align = 1000 (ofset du dernier caractère imprimé)
Print_Right a,Align
Print_Right b,Align
Print_Right c,Align
Print_Right d,Align

Private sub Print_Right(byval Text as string, byval
Col as long)
with Printer
.currentX = Col - .TextWidth(Text)
End with
Printer.print text
End sub

Sur le même principe, on peut définir les procédures
Print_Left et Print_Center etc.....

-----Message d'origine-----
j'imprime une liste de chiffres comme ceci :

dim a, b, c , d as long
a = 10500
b= 50
c = 1250
d = 152030

printer.print
printer.print tab(30) ;a
printer.print tab(30) ;b
printer.print tab(30) ;c
printer.print tab(30) ;d
printer.EndDoc

comment procéder pour faire en sorte que ces chiffres


soient alignés a
l'impression.
merci,
dav
.



Avatar
dav
a écrit :

Bonjour,

Personnellement, j'utilise la méthode suivante :

Dim Align as long

Align = 1000 (ofset du dernier caractère imprimé)
Print_Right a,Align
Print_Right b,Align
Print_Right c,Align
Print_Right d,Align

Private sub Print_Right(byval Text as string, byval
Col as long)
with Printer
.currentX = Col - .TextWidth(Text)
End with
Printer.print text
End sub

Sur le même principe, on peut définir les procédures
Print_Left et Print_Center etc.....


-----Message d'origine-----
j'imprime une liste de chiffres comme ceci :

dim a, b, c , d as long
a = 10500
b= 50
c = 1250
d = 152030

printer.print
printer.print tab(30) ;a
printer.print tab(30) ;b
printer.print tab(30) ;c
printer.print tab(30) ;d
printer.EndDoc

comment procéder pour faire en sorte que ces chiffres



soient alignés a

l'impression.
merci,
dav
.









ça marche impec, je te remercie, mais a quoi sert le

align00

ça signifie quoi, ofset du dernier caractere...???
merci,
dav
Avatar
Jean-Marc
Hello,

pour Offset, un peu de lecture:
http://web.infomaniak.ch/support/jargon_article.php?iCodeArticle559

Pour Align, c'est simple:
Align = 1000 (ofset du dernier caractère imprimé)
Print_Right a,Align ' <-- Align est le second paramètre d'appel à
Print_Right
donc lors de l'appel à :
Private sub Print_Right(byval Text as string, byval Col as long)

Col prend la valur de Align, qui et utilisé ici:
.currentX = Col - .TextWidth(Text)

Pour en savoir plus sur les fonctions et procédures,
un peu de lecture:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconprogrammersguide.asp

Pout l'objet Printer, un peu de lecture:
Extrait de l'aide en ligne:
----
CurrentX, CurrentY Properties
Return or set the horizontal (CurrentX) or vertical (CurrentY)
coordinates for the next printing or drawing method. Not available
at design time.
----

Et un peu plus de lecture encore (mais indispensable):
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconprogrammersguide.asp

Enfin, pour revenir à ton code:
dim a, b, c , d as long





Attention! Cette déclaration ne fait pas ce que tu crois.
Elle déclare d de type long, mais a,b,c sont des Variants!

Un peu de lecture:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconprogrammersguide.asp


Bonne lecture!

--
Jean-marc
"There are only 10 kind of people
those who understand binary and those who don't."


"dav" a écrit dans le message de
news:41641e7f$0$17802$
a écrit :

> Bonjour,
>
> Personnellement, j'utilise la méthode suivante :
>
> Dim Align as long
>
> Align = 1000 (ofset du dernier caractère imprimé)
> Print_Right a,Align
> Print_Right b,Align
> Print_Right c,Align
> Print_Right d,Align
>
> Private sub Print_Right(byval Text as string, byval
> Col as long)
> with Printer
> .currentX = Col - .TextWidth(Text)
> End with
> Printer.print text
> End sub
>
> Sur le même principe, on peut définir les procédures
> Print_Left et Print_Center etc.....
>
>
>>-----Message d'origine-----
>>j'imprime une liste de chiffres comme ceci :
>>
>>dim a, b, c , d as long
>>a = 10500
>>b= 50
>>c = 1250
>>d = 152030
>>
>>printer.print
>>printer.print tab(30) ;a
>>printer.print tab(30) ;b
>>printer.print tab(30) ;c
>>printer.print tab(30) ;d
>>printer.EndDoc
>>
>>comment procéder pour faire en sorte que ces chiffres
>
> soient alignés a
>
>>l'impression.
>>merci,
>>dav
>>.
>
>>

ça marche impec, je te remercie, mais a quoi sert le

align00

ça signifie quoi, ofset du dernier caractere...???
merci,
dav


Avatar
jean-marc
Hello,

je m'apperçois seulement que certains de mes liens étaient
mal passés. Les revoila plus utilisables:

Références de l'Objet Printer
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/html/v
bobjPrinter.asp

Usage du statement Dim
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/ht
ml/vastmDim.asp

Usage de Sub
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/ht
ml/vastmSub.asp

--
Jean-marc
"There are only 10 kind of people
those who understand binary and those who don't."
Avatar
ng
Salut,
Attention !!!

dim a, b, c , d as long



N'est pas équivalent à Dim a As Long, b As Long, c As Long, d as Long

En VB, toutes les variables doivent être typ"es explicitement ! Sinon on se
retrouve en Variant.

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/


dav wrote:
j'imprime une liste de chiffres comme ceci :

dim a, b, c , d as long
a = 10500
b= 50
c = 1250
d = 152030

printer.print
printer.print tab(30) ;a
printer.print tab(30) ;b
printer.print tab(30) ;c
printer.print tab(30) ;d
printer.EndDoc

comment procéder pour faire en sorte que ces chiffres soient alignés a
l'impression.
merci,
dav