Results 1 to 3 of 3

Thread: ListBox why won't it let me.......

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Location
    London, UK
    Posts
    137
    I am trying to take the contents of the ListBox and copy them into a variable ready to be pumped into a DB.

    However I can't read in the value of the ListBox???

    Has anyone come across this befor..........What should the correct sytax if the statement be??


    Any remarks would be cool



    Cheers
    join me in the platinum

  2. #2
    Lively Member
    Join Date
    Sep 1999
    Location
    Liverpool, UK
    Posts
    64
    Dim listboxdata() As String

    'Store the data from the list box
    For x = 0 To List1.ListCount - 1
    ReDim Preserve listboxdata(x + 1)
    listboxdata(x + 1) = List1.List(x)
    Next x

    For x = 1 To UBound(listboxdata)
    listboxdata(x) add to database....
    Next x

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Private Sub Command1_Click()
        Dim i As Integer
        For i = 1 To 10
        List1.AddItem i
        Next i
        
     Dim myArr()
     
    For i = 0 To List1.ListCount - 1
      List1.ListIndex = i
      ReDim Preserve myArr(i)
      myArr(i) = List1.Text
      Next i
      
    End Sub
    'now you have the contents loaded into an array and you
    'can populate your file with the information.
    'open the db and what not
    'to add the rec use a loop
    For i = LBound(myArr) To UBound(myArr)
        Data1.addnew
        Data1.Recordset!yourfield = myArr(i)
        Data1.Update
        Next i
    'close or whatever.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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