D
DimR
<!--shcode--><pre><code class='vb'>Sub ListBoxes()
Dim str(5) As String, strInfo(5) As String, surn(5) As Boolean
Dim i As Byte, idCount As Byte
str(0) = "1"
str(1) = "2"
str(2) = "3"
str(3) = "4"
str(4) = "5"
str(5) = "6"
idCount = 0
UserForm2.ListBox1.Clear
UserForm1.ListBox1.Clear
UserForm1.ListBox1.Enabled = False
UserForm2.ListBox1.Enabled = True
With UserForm2.ListBox1
For i = 0 To 5
.AddItem str(i)
surn(i) = False
Next i
.ListIndex = 0
.MultiSelect = fmMultiSelectExtanded
End With
' ошибка начинается ниже
If UserForm2.ListBox1.ListCount > 0 Then
For i = 0 To UserForm2.ListBox1.ListCount - 1
surn(i) = UserForm2.ListBox1.Selected(i)
If surn(i) Then
strInfo(idCount) = str(i)
UserForm1.ListBox1.AddItem strInfo(idCount)
idCount = idCount + 1
End If
Next i
UserForm1.ListBox1.Enabled = False
UserForm2.ListBox1.Enabled = True
UserForm1.ListBox1.MultiSelect = fmMultiSelectExtanded
End If
End Sub[/CODE]
Не понимаю в чём ошибка: отображается только первый элемент списка
Dim str(5) As String, strInfo(5) As String, surn(5) As Boolean
Dim i As Byte, idCount As Byte
str(0) = "1"
str(1) = "2"
str(2) = "3"
str(3) = "4"
str(4) = "5"
str(5) = "6"
idCount = 0
UserForm2.ListBox1.Clear
UserForm1.ListBox1.Clear
UserForm1.ListBox1.Enabled = False
UserForm2.ListBox1.Enabled = True
With UserForm2.ListBox1
For i = 0 To 5
.AddItem str(i)
surn(i) = False
Next i
.ListIndex = 0
.MultiSelect = fmMultiSelectExtanded
End With
' ошибка начинается ниже
If UserForm2.ListBox1.ListCount > 0 Then
For i = 0 To UserForm2.ListBox1.ListCount - 1
surn(i) = UserForm2.ListBox1.Selected(i)
If surn(i) Then
strInfo(idCount) = str(i)
UserForm1.ListBox1.AddItem strInfo(idCount)
idCount = idCount + 1
End If
Next i
UserForm1.ListBox1.Enabled = False
UserForm2.ListBox1.Enabled = True
UserForm1.ListBox1.MultiSelect = fmMultiSelectExtanded
End If
End Sub[/CODE]
Не понимаю в чём ошибка: отображается только первый элемент списка