Home > Software engineering >  Novice asked one of the most simple cycle
Novice asked one of the most simple cycle

Time:10-11

(1, 4-trichlorobenzene) listbox2 of listbox1 has a button button (1, 3), how to implement listbox3 appear in the same number (1), (2, 4,) appear in the listbox4, listbox5 in (3)
Will write the same number,
Dim As Integer I
Dim j As Integer
Dim ss
Dim bb
For I=0 To ListBox1. Items. The Count - 1
For j=0 To ListBox2 Items. The Count - 1
Ss=ListBox1. The Items (I)
Bb=ListBox2. Items (j)
If ss=bb Then
ListBox3. Items. The Add (ss)
End the If
Next j
Next I

CodePudding user response:

 Option Explicit 
Private Declare Function SendMessagebyString Lib "user32" Alias "SendMessageA" (ByVal hWND As Long, _
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long As String)

Private Const LB_FINDSTRINGEXACT=& amp; H1A2

Private Sub Command1_Click ()
Dim As Long I

List3. Clear
List4. Clear
For I=0 To List1. ListCount - 1
If 1=SendMessagebyString (List2. HWND LB_FINDSTRINGEXACT, 1, List1. List (I)) Then
List4. AddItem List1. List (I)
The Else
List3. AddItem List1. List (I)
End the If
Next I

List5. Clear
For I=0 To List2. ListCount - 1
If 1=SendMessagebyString (List3 hWND, LB_FINDSTRINGEXACT, 1, List2. List (I)) Then
List5. AddItem List2. List (I)
End the If
Next I
End Sub
  • Related