会VB的帮忙看看:loop缺少do......

来源:百度知道 编辑:UC知道 时间:2024/07/01 02:11:54
代码如下:
Adodc1.Recordset.MoveFirst
Do
g1 = Adodc1.Recordset.Fields("学号")
For I = 0 To n
If g1 = arr(I) Then j = j + 1
'End If
If gi <> arr(I) Then DataGrid1.Visible = False
'End If
If Adodc1.Recordset.EOF = True Then Exit Do
Adodc1.Recordset.MoveNext
Loop

不知道怎么总是提示loop 缺少do!
datagrid中的“学号”一列为所有学生的学号,数组arr()中只是部分学生的学号。我想实现的是找出在datagrid中但不在数组arr()中的学号,然后让datagrid那一行不显示。不知以上程序对不对?
谢谢啦!

是你的for差一个配对的next
你在合适的位置添加吧..因为不明白功能..
比如这样:

Do
g1 = Adodc1.Recordset.Fields("学号")
For I = 0 To n
If g1 = arr(I) Then j = j + 1
If gi <> arr(I) Then DataGrid1.Visible = False
next
If Adodc1.Recordset.EOF = True Then Exit Do
Adodc1.Recordset.MoveNext
Loop

Adodc1.Recordset.MoveFirst
Do
g1 = Adodc1.Recordset.Fields("学号")
For I = 0 To n
If g1 = arr(I) Then j = j + 1

If gi <> arr(I) Then DataGrid1.Visible = False
If Adodc1.Recordset.EOF = True Then Exit Do
Adodc1.Recordset.MoveNext
next'加上这一句
Loop

Do
g1 = Adodc1.Recordset.Fields("学号")
For I = 0 To n
If g1 = arr(I) Then j = j + 1
end if
If gi <> arr(I) Then DataGrid1.Visible = False
end if
next '加上这句
If Adodc1.Recordset.EOF = True Then Exit Do
Adodc1.Recordset.MoveNext
Loop