Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
16
Task/Align-columns/Visual-Basic/align-columns-1.vb
Normal file
16
Task/Align-columns/Visual-Basic/align-columns-1.vb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
Sub AlignCols(Lines, Optional Align As AlignmentConstants, Optional Sep$ = "$", Optional Sp% = 1)
|
||||
Dim i&, j&, D&, L&, R&: ReDim W(UBound(Lines)): ReDim C&(0)
|
||||
|
||||
For j = 0 To UBound(W)
|
||||
W(j) = Split(Lines(j), Sep)
|
||||
If UBound(W(j)) > UBound(C) Then ReDim Preserve C(UBound(W(j)))
|
||||
For i = 0 To UBound(W(j)): If Len(W(j)(i)) > C(i) Then C(i) = Len(W(j)(i))
|
||||
Next i, j
|
||||
|
||||
For j = 0 To UBound(W): For i = 0 To UBound(W(j))
|
||||
D = C(i) - Len(W(j)(i))
|
||||
L = Choose(Align + 1, 0, D, D \ 2)
|
||||
R = Choose(Align + 1, D, 0, D - L) + Sp
|
||||
Debug.Print Space(L); W(j)(i); Space(R); IIf(i < UBound(W(j)), "", vbLf);
|
||||
Next i, j
|
||||
End Sub
|
||||
Loading…
Add table
Add a link
Reference in a new issue