Home All Groups Group Topic Archive Search About

accessing listbox item value

Author
4 Jan 2006 4:02 PM
Candace
I am just learning to program and cannot figure out what is wrong with the
following line of code. I am trying to take the value of one item from a
ListBox and assign it to a string variable. Please help. Thanks.

            strExistingTime = lstTimes.Items.Item(intCounter).ToString()

Author
5 Jan 2006 2:15 PM
kevininstructor@state.or.us
If all you have for each item is text then this will work, how are you
loading your listbox?


Show quoteHide quote
"Candace" <Cand***@discussions.microsoft.com> wrote in message
news:372436B9-C1AE-4CC1-A746-E070D5DA08C5@microsoft.com...
>I am just learning to program and cannot figure out what is wrong with the
> following line of code. I am trying to take the value of one item from a
> ListBox and assign it to a string variable. Please help. Thanks.
>
>            strExistingTime = lstTimes.Items.Item(intCounter).ToString()
>
Author
5 Jan 2006 3:59 PM
Candace
Here is the portion of the code where I add info to the listbox:

      ' display new appointment in ListBoxes
      lstAppointments.Items.Add(txtAppointment.Text)
      lstTimes.Items.Add(dtpTime.Value.ToShortTimeString)


Show quoteHide quote
"kevininstruc***@state.or.us" wrote:

> If all you have for each item is text then this will work, how are you
> loading your listbox?
>
>
> "Candace" <Cand***@discussions.microsoft.com> wrote in message
> news:372436B9-C1AE-4CC1-A746-E070D5DA08C5@microsoft.com...
> >I am just learning to program and cannot figure out what is wrong with the
> > following line of code. I am trying to take the value of one item from a
> > ListBox and assign it to a string variable. Please help. Thanks.
> >
> >            strExistingTime = lstTimes.Items.Item(intCounter).ToString()
> >
>
>
>