我正在使用循環條件檢查列中是否存在空值,然後將其刪除。此循環出了什麼問題
[STart:]
For i As Integer = counter To dt1.Columns.Count - 1
For x As Integer = 0 To dt1.Rows.Count - 1
if some condition then
something = true
else
something = false
counter = counter + 1
Goto [Start]
end if
Next
If something = true
dt1.Columns.Remove(dt1.Columns(i))
i -= 1
End If
Next
End If
有時可以正常運行,有時即使當i
變得比(dt.columns.count - 1)
更大,但它仍然執行for循環,並拋出一個錯誤,沒有與該索引沒有列。我必須在這裏失去一些東西,但我無法調試問題。
你們是否發現此代碼有問題?
不知道爲什麼你在這裏得票低。這是本網站的內容。將問題發佈到其他程序員的網絡上。從我+1。 – 2010-02-15 21:32:45
我也不確定:(可能是他們是不錯的程序員,他們不喜歡我這樣的程序員犯錯誤並試圖學習 – 2010-02-15 21:40:29