Home > Software engineering >  VB how to extract the first in the second list box list box in the Z and Y?
VB how to extract the first in the second list box list box in the Z and Y?

Time:09-24

The List Box 1: aaaaaaaaaaaaaaa
BBBZBBBBBBBBBBB
Cccccccccccycccccc
DDDDDDDDDDDDDDD

The List box 2:?




A VB great god add QQ: 1024447356 or WeChat: lizhiyu0707 save lives!!!!!!


CodePudding user response:

 Private Sub Command1_Click () 
'on the left list to the right list
For I=0 To List1. ListCount - 1
If List1. Selected (I)=True Then
A=a + 1
End the If
Next I
If a=0 Then
MsgBox "in the text box on the left, please select the project", and "message"
The Exit Sub
End the If
List2. AddItem List1. Text
'List1. RemoveItem List1. ListIndex' if you need to list items on the left, remove the annotation can
End Sub

Private Sub Command2_Click ()
'list on the right to the left list
For I=0 To List2. ListCount - 1
If List2. Selected (I)=True Then
A=a + 1
End the If
Next I
If a=0 Then
MsgBox "please select the project in the text box on the right", and "message"
The Exit Sub
End the If
'List1. AddItem List2. Text' if you need to add items to the list of the left can be removed comments
List2. RemoveItem List2. ListIndex
End Sub

Private Sub Form_Load ()
AA=Array (" aaaaaaaaa ", "BBBZBBBB", "CCCCCCCC", "DDDDDDDDD", "BBBBBBB", "cccyccc")
BB=UBound (AA)
For I=0 To BB
List1. AddItem AA (I)
Next I
End Sub

Very simple, modify the AA array data,

CodePudding user response:

I didn't understand what you mean...

CodePudding user response:

refer to the second floor Topc008 response:
I didn't understand what you mean...

I also do not understand,
Call you add he WeChat, QQ chat with,

CodePudding user response:

 Dim As Integer I 

List2. Clear
For I=0 To List1. ListCount - 1
If InStr (List1. List (I), "y") Then List2. AddItem List1. List (I)
If InStr (List1. List (I), "z") Then List2. AddItem List1. List (I)
Next I
  • Related