Results 1 to 8 of 8

Thread: [RESOLVED] listBox - problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Location
    in Poland
    Posts
    390

    Resolved [RESOLVED] listBox - problem

    Hi

    I have something like this

    Code:
    Option Explicit
    
    Private Declare Function SendMessage _
     Lib "user32" Alias "SendMessageA" ( _
     ByVal hwnd As Long, _
     ByVal wMsg As Long, _
     ByVal wParam As Long, _
     lParam As Any) As Long
    
    Private Sub Command1_Click()
    Unload Me
    End Sub
    
    Private Sub Form_Load()
        Dim nTabArray(1) As Long 'Two tab stops (= 3 columns)
        Const LB_SETTABSTOPS As Long = &H192
        
        nTabArray(0) = 33
        nTabArray(1) = 210
        
        'Clear any existing tabs
        'and set the list tabstops
        Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 0&, ByVal 0&)
        Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 2&, nTabArray(0))
        List1.Refresh
        'add some dummy data
        List1.AddItem "1" & vbTab & "Apples" & vbTab & "$2.98"
        List1.AddItem "2" & vbTab & "Chocolate" & vbTab & "$4.50"
        List1.AddItem "3" & vbTab & "Yoghurt" & vbTab & "$4.90"
        List1.AddItem "4" & vbTab & "Coffee" & vbTab & "$19.98"
        List1.AddItem "5" & vbTab & "Mango" & vbTab & "$2.00"
        List1.AddItem "6" & vbTab & "Bananas" & vbTab & "$1.89"
        List1.AddItem "7" & vbTab & "Olives" & vbTab & "$7.12"
    End Sub
    
    Private Sub List1_Click()
        Dim sItems() As String
        Dim i As Long
        sItems = Split(List1.Text, vbTab)
        For i = 0 To 2
            Text1(i).Text = sItems(i)
        Next
    End Sub
    how to make that every clicking it can do wrote into the next row with textboxes with next numb er ordinal.
    Attached Images Attached Images  
    I know, I know, my English is bad, sorry .....

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: listBox - problem

    IMO, use a listview instead. It will reduce lots of code and you'll get more advanced features.

    Edit:
    If you use a listview with gridlines, there is no need for the textbox array. You can make the listview editable by moving a textbox over cells. Search for "editable listview" or something like that.
    Last edited by iPrank; May 28th, 2007 at 03:07 PM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: listBox - problem

    Good point. Switch to listview buddy.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Location
    in Poland
    Posts
    390

    Re: listBox - problem

    Thanks for answers
    But....this has to be Listbox control unfortunately (with different of reasons) So....someone help me?
    I know, I know, my English is bad, sorry .....

  5. #5
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: listBox - problem

    Are the textboxes indexed like,

    0------1--------2
    3------4--------5
    6------7--------8
    9------10--------11

    In this case you can calculate the index of current textboxes if you store index of the 'last-textbox' (where you've entered text last time) in some variable.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Location
    in Poland
    Posts
    390

    Re: listBox - problem

    Hi
    Thank you for answer.
    Hmm, you would can show an some example because I don't know how I should to do it.
    I'm convinced, that it will the best visible on a some example, what about this you think?

    I greet Tamgovb
    I know, I know, my English is bad, sorry .....

  7. #7
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: listBox - problem

    Here is a sample project.
    Attached Files Attached Files
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Location
    in Poland
    Posts
    390

    Re: listBox - problem

    Ouuu iPrank, it's Cool. Very, very good

    Thank You iPrank
    I know, I know, my English is bad, sorry .....

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