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
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
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.
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
Yes, that is possible, but only if you use a fixed width font.
Just create a formatted string for each line you add.
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
What have you tried and how does it look?
...
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`
the output was still the same as the previews
You first need to determine the longest item from the first column. Use that value for each item you add.
But i don't know how to start. Please help. thank you
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 `
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.