Results 1 to 7 of 7

Thread: [RESOLVED] Populate a Listbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Posts
    251

    Resolved [RESOLVED] Populate a Listbox

    i have figured it out how to fill a listbox with a textfile

    but cant do the rest do have to split the string add them to the list index
    For i = 1 To UBound(split)

    my text file is like this

    one
    ......... blue
    ......... red
    tow
    ......... green
    ......... yellow

    i have 2 list box i want to load the string one and tow into list1
    and when a user click on a list1 item one fill the list2 index with

    blue
    red
    and so on

    thanks

    Private Sub Form_Load()
    Dim txtstring As String
    Open App.Path & "\pictuer.text" For Input As #1
    list1.Clear
    While Not EOF(1)
    Input #1, txtstring
    list1.AddItem txtstring
    Wend
    Close #1
    End Sub




    text file
    .............................
    one
    ......... blue
    ......... red
    tow
    ......... green
    ......... yellow

    Last edited by bordino; Jan 24th, 2010 at 03:24 AM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Posts
    251

    Re: Populate a Listbox

    cant make it work i dont know what im doing wrong here


    Dim LoadData
    Dim pic
    Dim num

    Private Sub List1_Click()

    List2.Clear
    num = Split(pic(List1.Index + 1), "*")
    For i = 1 To UBound(num)
    List2.AddItem (i)
    Next i

    End Sub


    Private Sub Form_Load()
    LoadTxtFile
    End Sub

    Public Sub LoadTxtFile()
    On Error GoTo dlgerror
    Dim sCurrent As String
    LoadData = ""
    Open App.Path & "\pictuer.txt" For Input As #1
    Do Until EOF(1)
    Line Input #1, sCurrent
    LoadData = LoadData & sCurrent
    Loop
    Close #1
    pic = Split(LoadData, "@")
    For i = 1 To UBound(pic)
    List1.AddItem (i)
    Next i
    dlgerror:
    Exit Sub
    End Sub


    my text file
    .......................................


    @one*
    blue*
    red*


    @tow*
    green*
    yellow *
    Last edited by bordino; Jan 24th, 2010 at 03:23 AM.

  3. #3
    Lively Member agent_007's Avatar
    Join Date
    Jan 2010
    Posts
    93

    Re: Populate a Listbox

    Quote Originally Posted by bordino View Post
    i have figured it out how to fill a listbox with a textfile

    but cant do the rest do have to split the string add them to the list index
    For i = 1 To UBound(split)

    my text file is like this

    one
    ......... blue
    ......... red
    tow
    ......... green
    ......... yellow

    i have 2 list box i want to load the string one and tow into list1
    and when a user click on a list1 item one fill the list2 index with

    blue
    red
    and so on

    thanks

    Private Sub Form_Load()
    Dim txtstring As String
    Open App.Path & "\chapter.text" For Input As #1
    list1.Clear
    While Not EOF(1)
    Input #1, txtstring
    list1.AddItem txtstring
    Wend
    Close #1
    End Sub




    text file
    .............................
    one
    ......... blue
    ......... red
    tow
    ......... green
    ......... yellow


    im currently working on it heres the code what i have come upto till now

    Code:
    Private Sub Form_Load()
    Dim txtstring, filt As String
    Open "c:\chapter.txt" For Input As #1
    List1.Clear
    Do Until EOF(1)
    Input #1, txtstring
    filt = Left(txtstring, 1)
    If filt <> "." Then
    List1.AddItem txtstring
    End If
    Loop
    Close #1
    End Sub
    
    Private Sub List1_Click()
    Dim a, btxtstring, filt As String
    Open "c:\chapter.txt" For Input As #1
    List2.Clear
    Do Until EOF(1)
    Input #1, txtstring
    filt = Left(txtstring, 1)
    If filt = "." Then
    List2.AddItem txtstring
    End If
    Loop
    Close #1
    End Sub

    Im Pro in C#,VB.NET,Batch,Socket Programming, SPY Software Programming, VB6, Win32Api, VBscript, Windows Registry, ASP.NET, PHP, Jquery, AJAX.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Posts
    251

    Re: Populate a Listbox

    thanks man

  5. #5
    gibra
    Guest

    Re: Populate a Listbox

    Quote Originally Posted by bordino View Post
    thanks man
    If your problem is solved, please MARK thread using
    Thread Tools menu link, then click to Mark Thread Resolved link

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 2008
    Posts
    251

    Re: [RESOLVED] Populate a Listbox

    here was the problem with my code

    List1.ListIndex

    thanks alot

  7. #7
    gibra
    Guest

    Re: [RESOLVED] Populate a Listbox

    Quote Originally Posted by bordino View Post
    here was the problem with my code
    List1.ListIndex
    What mean?
    List1.ListIndex isn't a problem, it's a property.
    What is the problem?

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