Date: 02-16-2022
Return to Index
'Sets start position of each column according to width of data
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
Function PBMain () As Long
Dim D(1 To 3,1 To 3) As Long 'col,row
Array Assign D() = 1111,2,3,4,555,6,7,8,999999 'colum major arrays
PrintArray D(), 100, 200, 100 'array, left margin, top margin, column gap
End Function
Sub PrintArray(D() As Long, LM As Long, TM As Long, Gap As Long)
Local i,j,ColEndPos As Long, temp$
XPrint Attach Default
'get max col width for each column
Dim MaxColWidth(3) As Long
For i = 1 To 3 'each col
For j = 1 To 3 'each row
MaxColWidth(i) = Max(MaxColWidth(i), XPrint(Text.Size.X,Format$(D(i,j),"###,###,##0.00")))
Next J
Next I
'xprint the content
ColEndPos = LM
For i = 1 To 3 'each col
ColEndPos += MaxColWidth(i) + Gap
For j = 1 To 3 'each row
temp$ = Format$(D(i,j),"###,###,##0.00")
XPrint Set Pos (ColEndPos - XPrint(Text.Size.X,temp$), TM + (j-1)* XPrint(Text.Size.Y,"X"))
XPrint temp$
Next j
Next i
XPrint Close
End Sub
'gbs_01440
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm