Friends , Is there any way for data alignment in the list box. My code is given below

Private Sub TxtFdt_KeyPress(KeyAscii As Integer)
Dim L, L1, L2, L3, L4, L5 As Integer
Select Case KeyAscii
Case vbKeyReturn
If TRS.State = adStateOpen Then TRS.Close
TRS.Open "SELECT * FROM Tran WHERE Ac = '" & TxtAc.Text & "'" & "and Acno=" & Val(TxtAcno.Text) & "and Tdate>= #" & TxtFdt.Text & "#" & "ORDER by Tdate,Trnno", CN, adOpenStatic, adLockOptimistic
If TRS.RecordCount = 0 Then
MsgBox "NO TRANSACTION FOR THIS PERIOD !", vbInformation, "PEBBLE"
TxtFdt.SetFocus
Else
TRS.MoveFirst
List1.Clear
Do Until TRS.EOF
L = Len(Left(TRS!Tdate, 10))
L = 10 - L
L1 = Len(Left(TRS!Details, 25))
L1 = 25 - L1
L2 = Len(Left(TRS!Debit, 10))
L2 = 10 - L2
L3 = Len(Left(TRS!Credit, 10))
L3 = 10 - L3
L4 = Len(Left(TRS!Cd, 2))
L4 = 2 - L4
L5 = Len(Left(TRS!Balance, 10))
L5 = 10 - L5
List1.AddItem Left(TRS!Tdate, 12) & Space(L) & Space(3) & Left(TRS!Details, 25) & Space(L1) & Space(5) _
& Left(TRS!Debit, 10) & Space(L2) & Space(7) & Left(TRS!Credit, 10) & Space(L3) & Space(1) _
& Left(TRS!Cd, 2) & Space(L4) & Space(3) & Left(TRS!Balance, 10)
TRS.MoveNext
Loop
CmdClear.SetFocus
End If
End Select
End Sub

My aim is to display the datas from a Database table in a list box under the field heads: Date,Details,Debit,Credit,Balance.It is working fine.The datas of Debit,Credit,Balance are of Number type.So I want them to be aligned to the right of the column. In my code it is aligned to the left of the field.Is there any way to align the number datas (only) to the right of the column? .....Please help..

Edited 2 Years Ago by mavtcr

O.K. You need to use a monospaced font which assigns each letter, number the same space, so an i would take up the same space as a w. Than you use the Rset function, where the number indecates how much you move your items to the right- depends on the width of the listbox. Here I post a few lines of code that demonstrates the use.

Private Sub Form_Load()
    List1.AddItem ("Hello")
    Dim strItem As String * 20
    RSet strItem = "Testing"
    List1.AddItem (strItem)
    Dim strItem1 As String * 10
    RSet strItem1 = "Testing"
    List1.AddItem (strItem1)
End Sub
This question has already been answered. Start a new discussion instead.