Kalsefar Posted March 6, 2022 Share Posted March 6, 2022 Hello All, I need code that helps me to copy the first Unselected element from a listBox to another, I already know how to copy all unselected elements as below but I need to copy just the first Element from the lisbox: For i As Integer = 0 To ListBox3.Items.Count - 1 If ListBox3.GetSelected(i) Then ListBox1.Items.Add(ListBox3.Items(i)) Else ListBox1.Items.Add(ListBox3.Items(i)) End If Next thanks Quote Link to comment Share on other sites More sharing options...
goran Posted May 19, 2022 Share Posted May 19, 2022 (edited) Usualy You can use Exit For, but then ..... hm, from Your's code items are copied from LB3 to LB1 no matter if they are selected or not. Or you can use something like this: DIm toCopy as Boolean toCopy = true itherate through list if item is unselected and toCopy copy element toCopy = false I am using c#, so VB(A) is somewhere between My ears.. Edited May 19, 2022 by goran Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.