如何把listbox1.listcount当作过程的参数
For i = 0 To ListBox1.ListCount
Next
有很多LISTBOX,需要做的事件是相同的,写一个SUB怎么把它当作参数了?
还有比如Textbox1.text当作参数
[解决办法]
Option Explicit
Private Sub Command1_Click()
ThroughList List1
End Sub
Private Sub Form_Load()
List1.AddItem "Item1"
List1.AddItem "Item2"
List1.AddItem "Item3"
End Sub
Sub ThroughList(ls As ListBox)
Dim i As Long
For i = 0 To ls.ListCount - 1
MsgBox ls.List(i)
Next
End Sub
[解决办法]
Option ExplicitPrivate Sub ListOp(ls As ListBox, te As TextBox)Dim i As LongFor i = 0 To ls.ListCount te.Text = te.Text & ls.List(i)Next iEnd SubPrivate Sub Command1_Click()ListOp List1, Text1ListOp List2, Text2End Sub