解決學生資訊管理系統之List列表中重複添加相同資料問題。

來源:互聯網
上載者:User
            學生資訊管理系統有很多錯誤需要我們去解決,下面我就解決一下在學生資訊管理系統中的“年級課程設定”表單裡出現的一個錯誤,“ list列表中重複添加資料”,當設定一個年級時課程時,你可重複添加一門課程好幾次!                  下面我展示一下解決“在list重複添加資料”的代碼!                 Private Sub cmdAdd_Click()
                    Dim i As Integer         '定義兩個整型變數
                    Dim j As Integer                   '往 listSelectcourse列表中添加課程                           If listAllcourse.ListIndex <> -1 Then
                                  listSelectcourse.AddItem listAllcourse.List(listAllcourse.ListIndex)  
                            End If
                            For i = 0 To listSelectcourse.ListCount - 1              '外迴圈
                                   For j = i + 1 To listSelectcourse.ListCount             '內迴圈                                                             '判斷在list列表中是否有相同的資料
                                         if  listSelectcourse.list(i)=listSelectcourse.list(j)  then                                                 listSelectcourse.RemoveItem  j    '刪除添加的資料                                                  msgbox"已有添加課程,請先刪除在添加!"                                                  exit sub                                           end  if                                     next   j                         next i           end  sub

                                                
                            這樣就可以了,list表中不會再重複添加相同的資料了。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.