CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: List Box Issue

  1. #1
    Join Date
    Jul 1999
    Posts
    5

    List Box Issue

    Hi All, my previous post errored out
    Here goes short and sweet.

    I have a list box with multiple selection capability. I'm currently showing one column value dept code and passing that value to the target SQL, however I need to have two columns show in the list box dept. code and department and pass only the dept. code value to the targeted SQL

    Example:
    Dept.Code Department
    0112S Finance

    I can't use this code lstDept.ItemData(lstDept.NewIndex)because dept. code is not an integer.

    Here is my FOR loop that reviews the list box value selected.
    For i = 0 To Me.lstDept.ListCount - 1
    If lstDept.Selected(i) = True Then
    Criteria = Criteria & "'" & Trim(Me.lstDept.List(i)) & "'" & ","
    End If
    Next i

    How do I pass only the department code??

    Thanks in advance


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: List Box Issue

    in addition to adding an item to the listbox using listbox1.Additem syntax I'd also fill an Array of strings with the corresponding dept code.
    (
    dim deptcode() as string
    dim i as integer
    list1.additem deptName
    redim deptcode(i)
    deptcode(i) = deptCode
    i = i+1
    )
    Then, when it's time to iterate over all selected items:

    for i = 0 to list1.listcount-1
    if list.selected(i) then
    dc = deptCode(i)
    criteria=...
    endif
    next i





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

Featured