office交流網--QQ交流群號

Access培訓群:792054000         Excel免費交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

VBA在列錶框ListBox指定行插入數據項目

2019-07-07 11:47:00
zstmtony
原創
9733

VBA在列錶框ListBox指定行插入數據項目

Listbox的additm 第2箇蔘數 可指定插入的位置

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

分享