|
-
Nov 18th, 2000, 06:53 PM
#1
Thread Starter
Lively Member
i am adding stuff to a list for example a "Name" and a "PhoneNo". No obviously the list will look like this:
Billy Bob 556-7895
Bobby 456-7895
Jim 123-7845
Timy Boy 789-4562
now how can i add the right number of spaces so that the items align like this:
Billy Bob 556-7895
Bobby 456-7895
Jim 123-7845
Timy Boy 789-4562
please help i think this can be done using the space() function but damn how????
-
Nov 18th, 2000, 06:59 PM
#2
Thread Starter
Lively Member
i am adding stuff to a list for example a "Name" and a "PhoneNo". Now obviously the list will look like this:
Billy Bob 556-7895
Bobby 456-7895
Jim 123-7845
Timy Boy 789-4562
now how can i add the right number of spaces so that the items align like this:
Billy Bob-556-7895
Bobby-----456-7895
Jim-------123-7845
Timy Boy--789-4562
please help i think this can be done using the space() function but damn how????
-
Nov 18th, 2000, 09:00 PM
#3
Junior Member
Set the Columns value of your list box to 2.
Then add this to your code where needed
Me.List1.AddItem ("Billy Bob" & vbTab & "556-7895")
Me.List1.AddItem ("Bobby" & vbTab & "456-7895")
Me.List1.AddItem ("Jim" & vbTab & "123-7845")
Me.List1.AddItem ("Timy Boy" & vbTab & "123-7845")
-
Nov 18th, 2000, 10:30 PM
#4
PowerPoster
Mid Function
Hi dangr, your solution will casue the phone number out of alignment too when this happen...
Code:
List1.AddItem ("Billy Bob ABC" & vbTab & "556-7895")
List1.AddItem ("Bobby" & vbTab & "456-7895")
List1.AddItem ("Jim" & vbTab & "123-7845")
List1.AddItem ("Timy Boy" & vbTab & "123-7845")
End Sub
So, you can try to do it in this way, But be careful of the ListBox Font type that you use. You need to use those font that have the same Weight for all charaters like Courier or Courier New.
Code:
Dim data As String
data = String(100, Chr(32))
Mid(data, 1) = "Billy Bob ABC"
Mid(data, 30) = "556-7895"
List2.AddItem data
data = String(100, Chr(32))
Mid(data, 1) = "Bobby"
Mid(data, 30) = "456-7895"
List2.AddItem data
data = String(100, Chr(32))
Mid(data, 1) = "Jim"
Mid(data, 30) = "123-7845"
List2.AddItem data
data = String(100, Chr(32))
Mid(data, 1) = "Timy Boy"
Mid(data, 30) = "123-7845"
List2.AddItem data
-
Nov 18th, 2000, 11:19 PM
#5
Junior Member
Put this in a module *.bas
Public Declare Function SendMessage Lib _
"user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Public Const LB_SETTABSTOPS = &H192
And this code for the form:
Private Sub Form_Load()
Dim TabStop As Long
TabStop = 120
'set the tabs
Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 1, TabStop)
Me.List1.AddItem ("Billy Bob" & vbTab & "556-7895")
Me.List1.AddItem ("Bobby" & vbTab & "456-7895")
Me.List1.AddItem ("Jim" & vbTab & "123-7845")
Me.List1.AddItem ("Timy Boy" & vbTab & "123-7845")
End Sub
-
Nov 18th, 2000, 11:26 PM
#6
PowerPoster
Wow, a good SendMessage + SETLBTABSTOPS API function call. I better use your method in my coming up program.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|