Re: [VB6 ] ListBox的刪除問題
※ 引述《fumizuki (矇面加菲獅)》之銘言:
: ※ 引述《Guestion (Question)》之銘言:
: : 如果ListBox的MultiSelect為單選時,要刪除選取的資料為:
: : If List1.ListIndex >=0 Then
: : List1.RemoveItem List1.ListIndex
: : End If
: : 但如果MultiSelect為多選時,以上的程式好像會出錯
: : 請問該如何修改呢?
: If List1.MultiSelect = 0 Then '單選
: If List1.ListIndex >= 0 Then List1.RemoveItem List1.ListIndex
: Else '複選
: For i = List1.ListCount - 1 To 0 Step - 1
: If List1.Selected(i) Then List1.RemoveItem i
: Next
: End If
抱歉還是有點不太明白...
如果i= ListCount-1 to 0 的話
這樣listindex會隨著listcount改變
但如果是i= 0 to ListCount-1
listindex還會改變嗎? 或者會影響的不是這部分?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.113.27.57
推
02/07 08:44, , 1F
02/07 08:44, 1F
推
02/07 12:36, , 2F
02/07 12:36, 2F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章