Option ExplicitDim strT() As String Private Sub Command1_Click() Dim i As Long ReDim strT(0 To List1.ListCount - 1) For i = 0 To List1.ListCount - 1 Text1.Text = Text1.Text & List1.List(i) '导入文本框中 strT(i) = List1.List(i): Debug.Print strT(i) '导入数组中 Next End SubPrivate Sub Form_Load() Dim i As Long Text1.Text = "" For i = 0 To 10 List1.AddItem "第" & i + 1 & "项" Next End Sub
Private Sub Command1_Click()
Dim i As Long
ReDim strT(0 To List1.ListCount - 1)
For i = 0 To List1.ListCount - 1
Text1.Text = Text1.Text & List1.List(i) '导入文本框中
strT(i) = List1.List(i): Debug.Print strT(i) '导入数组中
Next
End SubPrivate Sub Form_Load()
Dim i As Long
Text1.Text = ""
For i = 0 To 10
List1.AddItem "第" & i + 1 & "项"
Next
End Sub
存入数组方法:使用循环将ListBox中的每行数据逐一写入数组中。
写入TextBox方法:设置TextBox的MultiLine=True,通过循环将ListBox中的数据一行一行的写入TextBox,并使用vBCrlf分行。
Text1.Text = Text1.Text + List1.List(i) + vbcrlf