7,763
社区成员
发帖
与我相关
我的任务
分享
Private Sub List1_Click()
Dim i As Integer
Text1 = ""
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then Text1 = Text1 & List1.List(i)
Next i
End Sub
Private Sub List1_Click()
Dim i As Long
i = List1.ListIndex
If (List1.ItemData(i) = 0) Then
Text1.Text = Text1.Text & List1.List(i)
List1.ItemData(i) = -1
End If
End Sub
只是要注意,每次List1.clear 时,最好也把Text1清空。
Private Sub Form_Load()
List1.AddItem "AAA"
List1.AddItem "BBB"
List1.AddItem "CCC"
List1.AddItem "DDD"
List1.AddItem "EEE"
List1.AddItem "FFF"
List1.AddItem "GGG"
List1.AddItem "HHH"
List1.ListIndex = 0
End Sub
Private Sub List1_Click()
Dim I As Integer
Text1.Text = ""
For I = 0 To List1.ListCount - 1
If List1.Selected(I) Then Text1.Text = Text1.Text & IIf(Len(Text1.Text) = 0, "", ",") & List1.List(I)
Next
End Sub
Open "C:\1.txt" For Output As #1
T = Text1.Text
Print #1, T
Close #1
Text1.Text = ""
Open "C:\2.txt" For Input As #2
Input #1, str1
Close #1
Text1.Text = str1
If List1.Selected(0) = True Then
Text1.Text = Text1.Text & List1.List(0)
else
Text1.Text =Replace(Text1.Text," List1.List(0)","")
End If
If List1.Selected(1) = True Then
Text1.Text = Text1.Text & List1.List(1)
else
Text1.Text =Replace(Text1.Text," List1.List(1)","")
End If
If List1.Selected(2) = True Then
Text1.Text = Text1.Text & List1.List(2)
else
Text1.Text =Replace(Text1.Text," List1.List(2)","")
End If