假定文本框在Form1,列表框在Form2,则以下代码放在Form2:
Private Sub List1_Click()
Dim s As String, i As Integer
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then
If s <> "" Then s = s & ","
s = s & List1.List(i)
End If
Next
obj.Text = s
End Sub
以下代码放在Form1:
Private Sub Command1_Click() '第一个文本框后面的+按钮
Set Obj = Text1
Form2.Show
End Sub
Private Sub Command2_Click() '第二个文本框后面的+按钮
Set Obj = Text2
Form2.Show
End Sub
以下代码放在公共模块(Module)文件:
Public obj As Object