•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 426,424 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,384 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 1798 | Replies: 4
![]() |
•
•
Join Date: Nov 2007
Location: � Jogja �
Posts: 2,585
Reputation:
Rep Power: 11
Solved Threads: 235
you want to copy selected only, this will answer your question:
hope this helps...
Private Sub Command3_Click() List2.AddItem (List1.ListIndex) End Sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Feb 2008
Location: Sivakasi, Tamilnadu, India
Posts: 458
Reputation:
Rep Power: 1
Solved Threads: 79
•
•
•
•
I want to copy the selected items from listbox1 to listbox2.
I know how to copy all the items but not selected.
Private Sub Command3_Click()
For i = 1 To List1.ListCount
List2.AddItem i
Next
End Sub
Above Code will copy all the items,But I want to copy selected items.
hi mansi, this is the completely code for you. make sure you have set the multiselect property of your listbox control to 2-Extended.
Option Explicit
Private Sub Command1_Click()
Dim i As Integer, c As Integer
If List1.ListCount = 0 Then
MsgBox "No items found."
Exit Sub
End If
c = 0
For i = 0 To List1.ListCount - 1 Step 1
If List1.Selected(i) = True Then
c = 1
Exit For
End If
Next i
If c = 0 Then
MsgBox "Please select some items from the list."
List1.SetFocus
Exit Sub
ElseIf c = 1 Then
For i = 0 To List1.ListCount - 1 Step 1
If List1.Selected(i) = True Then
List2.AddItem List1.List(i)
End If
Next i
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 12 Step 1
List1.AddItem MonthName(i)
Next i
End Subregards
Shouvik
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- How do i print from a listbox?? (Visual Basic 4 / 5 / 6)
- how to bring the items at list view to the another form (VB.NET)
- simple cash register (pos) problem - please help!! (VB.NET)
- Select files in a listbox (Python)
- calculating sum, average, highest and lowest grades (Visual Basic 4 / 5 / 6)
- Outlook (C#)
- Quick directory question (C#)
- Populating & Retrieving Data in a listbox : ASP.NET (w/ VB.NET) (ASP.NET)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: How to stop and pause music files in runtime
- Next Thread: Textbox properties



Linear Mode