如果国家/地区已出现在 Datagrid 中,我希望阻止用户将国家/地区添加到数据库中。
Datagrid 预加载了表单加载事件中的国家/地区。
我有以下代码(如下),但是我收到一条错误消息,指出下标超出范围并且不能为负数。
Dim appear As Integer
Dim colcount As Integer
Dim rowcount As Integer
colcount = all_countries.ColumnCount
rowcount = all_countries.RowCount
For i = 0 To rowcount
For j = 0 To colcount
If (new_country.Text = all_countries.Item(colcount, rowcount).Value) Then
MsgBox("Country Exists", 0)
appear = 1
End If
Next
Next