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 9, PBWin 10
#Compile Exe
Function PBMain () As Long
Dim D(1 To 3,1 To 3) As String '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 String, LM As Long, TM as Long, Gap As Long)
Local i,j,ColStartPos As Long
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,D(i,j)))
Next J
Next I
'xprint the content
ColStartPos = LM
For i = 1 To 3 'each col
For j = 1 To 3 'each row
XPrint Set Pos (ColStartPos, TM + (j-1)* XPrint(Text.Size.Y,"X"))
XPrint D(i,j)
Next j
ColStartPos += MaxColWidth(i) + Gap
Next i
XPrint Close
End Sub
'gbs_01439
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm