hello
i try to use padright and padleft to beautify the aspect of my prints. I 'd
like the text to be print in two columns but i don't know the size of each
string before (because they are randomly generated) I thought that padright
complete the lenght of a string to the size noticed as a variable like
padright (50) if the string is 35 of lenght so padright add 15 to fit to
the given size of 50. But it seems it doesn't work like this ? Can some one
tell what doesn't work in this code ?
m_Paragraphs = New Collection
Dim mtEspaces As String = " = .......... "
For i As Integer = 1 To 20
Dim myStr1 As String = NbE(CShort(utility.GenNombre(Min, Max))) 'to build a
long number like 9 352
Dim myStr2 As String = NbE(CShort(utility.GenNombre(Min, Max))) 'to build a
long number like 9 352
m_Paragraphs.Add(New ParagraphInfo(11, i.ToString + ") ".PadRight(5) &
myStr1.PadRight(5) & mtEspaces.PadRight(50) & myStr2.PadRight(5) &
mtEspaces))
m_Paragraphs.Add(New ParagraphInfo(9, vbCrLf))
Next
the string are not aligned in two columns....
thanks for help
pascal
http://www.scalpa.info
Rick - 21 Apr 2007 10:22 GMT
I didn't look at your code carefully, but you have to use a monospaced font
for your concept to work in general. Courier is an example.
Other fonts have varing character widths so a space is less width than a
"W".
You might also try to imbed a tab character (Chr(9)) and see if that works.
Rick
> hello
>
[quoted text clipped - 31 lines]
>
> http://www.scalpa.info
Pascal - 21 Apr 2007 11:53 GMT
thank you, you were right and also i have to calculate the longest string
before to apply a padright lenght according to this variable
thank again
pascal
Göran Andersson - 21 Apr 2007 21:42 GMT
> hello
>
[quoted text clipped - 31 lines]
>
> http://www.scalpa.info
The expression i.ToString + ") ".PadRight(5) always creates the same
result, namely the same as i.ToString + ") ". If you want to pad the
string including the number, you have to add parentheses so that the
entire string is padded, not just the second string:
(i.ToString + ") ").PadRight(5)

Signature
Göran Andersson
_____
http://www.guffa.com
Pascal - 23 Apr 2007 20:47 GMT
Oh yes you are right
thank you