Results 1 to 4 of 4

Thread: Error accessing record in listbox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    68

    Unhappy Error accessing record in listbox

    Hi all, i got error clicking of the records found in e list box.They highlight this code got error.
    ' Get Primary Key from Listbox
    objListItem = CType(ListBox1.SelectedItem, ListBox)
    I dun noe y, i cannot select the list box item to be show in e textbox.
    Please hear fr ur reply soon, cos i need this urgently, due date soon.
    10q

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You are casting the item to a listbox that not right. A listbox probably doesn't have listboxes for items.

    objListItem = CType(ListBox1.SelectedItem, ListBox)

    That should be whatever you want to cast it to.

  3. #3
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    I'm guessing that you have strings in the listbox. If thats the case then you can try this
    VB Code:
    1. Dim objListItem As String = CType(ListBox1.SelectedItem, String)
    or
    VB Code:
    1. Dim lstItem as String = ListBox1.SelectedItem.ToString()
    2. MessageBox.Show(lstItem)

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2003
    Posts
    68
    I cannot got error with that line of the code, can u pls help mi?

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