[求助] 请教listbox的additem方法的用法
怎么用listbox的additem方法在插入时指定索引,不默认插入在最后面啊?
Option Explicit
Dim A As String
Dim B As Integer
Dim C As Integer
Dim I As Integer
Private Sub CMDADD_Click()
B = InputBox("想添加到第几行?")
C = List1.ListCount
If B < 0 Or B > C + 1 Then
InputBox ("请不要超过现有行数,请重新输入")
Else
If Text1.Text = "" Then
MsgBox ("请在文本框中输入内容")
Else
For I = C To B Step -1
List1.List(I) = List1.List(I - 1)
Next I
List1.AddItem Text1.Text, (B - 1)
End If
End If
End Sub