0

is it possible to apply this kind of alignment in vb6 listbox?

Ex.

aaa     bbfawdawd
bbbb    adwadwa
cc      dawdawda

if it is possible. Please specify the solution. thank you

Edited by jeffersonalomia

3
Contributors
10
Replies
24
Views
6 Months
Discussion Span
Last Post by Minimalist
Featured Replies
  • 1

    Yes, that is possible, but only if you use a fixed width font. Just create a formatted string for each line you add. Read More

0

There are components that do this (try a search engine), or you could try and write it yourself, but the better solution would be to use a ListView instead.

0

I started to build the application using listbox, and it is almost finish. Is it possible to align that using a space() function and use the difference of array1(0) length to array1(1) length?

Ex.
len(array1(0)) = 10
len(array1(1)) = 5

10 - 5

lbx.additem wdawdawd & space(5) & dawdawdaw
lbx.additem dwadaw & space(5) & dwadwad

Edited by jeffersonalomia

1

Yes, that is possible, but only if you use a fixed width font.

Just create a formatted string for each line you add.

Comments
That's it. "Fixed width font"
0

I am confuse on constructing. Once ive try that, the output doesnt goes to what i wanted to. How do i implement that in vb6

0

...

Edited by jeffersonalomia

Attachments
Public Sub display_records()
        Dim db_rec() As String
        Dim l1, l2, diff As Integer
        
        sql = "SELECT * FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_SCHEMA='" & selected_db & "';"
        Set rs = cn.Execute(sql)
        i = 0
        Do While Not rs.EOF
            
            ReDim Preserve db_rec(i + 1)
            db_rec(i) = rs("TRIGGER_NAME")
            i = i + 1
            rs.MoveNext
        Loop
        
        
            For j = 0 To i - 1
                l1 = Len(db_rec(j))
                l2 = Len(db_rec(j + 1))
        
                If l1 > l2 Then
                    diff = l1 - l2
                End If
                If l2 > l1 Then
                    diff = l2 - l1
                End If
       Form7.lst_prompt.AddItem db_rec(j) & Space(diff + 30) & txt_trigger_val(j)
    
        Next j
`End Sub`
0

Its properly much easier to work from the lefthand side of the list. You just roughly know the max length of the first string, give some space and add the second. so if x is the length of the max length string ,say 12, you do space(-x+15) & next string. This will place the second string always at pos 15,regardless of the length of the first string.
`Private Sub Form_Load()
Dim str1 As String
Dim str2 As String
Dim x As Integer
Dim x1 As Integer

str1 = "abc"
str2 = "abcdef"
x = Len(str1)
x1 = Len(str2)
List1.AddItem (str1) & Space(-x + 15) & (str1)
List1.AddItem (str2) & Space(-x1 + 15) & (str2)
End Sub Linup.jpg `

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.