Always Copying Last Line From Listbox

Ian96
07-14-2004, 08:59 AM
I want code to copy the last item in the listbox to a textbox what ever the amount of items in the listbox

1. John

The Textbox would say john

1. John
2. Samantha

The textbox would say samantha etc so it is always reading the last one.

Hope someone can help

00100b
07-14-2004, 09:06 AM
Me.Text1.Text = Me.List1.List(Me.List1.ListCount - 1)

The ListCount property identifies the number of items in the list. By subtracting 1 from that value (since the List collection is 0-based) you can derive the ListIndex of the last item in the List.

dipique
07-14-2004, 09:07 AM
I want code to copy the last item in the listbox to a textbox what ever the amount of items in the listbox

1. John

The Textbox would say john

1. John
2. Samantha

The textbox would say samantha etc so it is always reading the last one.

Hope someone can help

Text1.Text = List1.List(List1.ListCount - 1)

Dan

After Note: He got here first:(

Ian96
07-14-2004, 09:09 AM
Oh i see yeh Thanks i will test it later as it looks small enough code to work. I have not tested the variable code you gave me 00100b because i needed this to work first as the name in the textbox will be the variable. I will test it later and reply to the other post. Thanks!!!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum