Results 1 to 6 of 6

Thread: ***---Damn easy please help---***

  1. #1

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92

    Exclamation

    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????

  2. #2

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92
    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????

  3. #3
    Junior Member
    Join Date
    Oct 2000
    Posts
    19
    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")

  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up 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

  5. #5
    Junior Member
    Join Date
    Oct 2000
    Posts
    19

    Thumbs up

    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

  6. #6
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    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
  •  



Click Here to Expand Forum to Full Width