534
技術社區[雲棲]
如何防止顯示全部上機學生時重複
在做機房收費係統查看學生上機狀態中,顯示全部信息時,發現會出現重複的卡號,後來查了又查,改了又改,加了個簡單的循環,便避免了這種情況Private Sub showAll_Click()
Dim txtsqlOn As String
Dim msgtext As String
Dim mrcOn As ADODB.Recordset
Dim i As Integer
Dim j As Integer
txtsqlOn = "select * from online_info"
Set mrcOn = executeSQL(txtsqlOn, msgtext)
With myFlexGrid
.CellAlignment = 4
.Rows = 1
.TextMatrix(0, 0) = "卡號"
.TextMatrix(0, 1) = "姓名"
.TextMatrix(0, 2) = "上機日期"
.TextMatrix(0, 3) = "上機時間"
.TextMatrix(0, 4) = "機房號"
Do While Not mrcOn.EOF
.CellAlignment = 4
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = mrcOn!cardno
.TextMatrix(.Rows - 1, 1) = mrcOn!studentname
.TextMatrix(.Rows - 1, 2) = mrcOn!ondate
.TextMatrix(.Rows - 1, 3) = mrcOn!OnTime
.TextMatrix(.Rows - 1, 4) = mrcOn!computer
mrcOn.MoveNext
For i = 0 To .TextMatrix(.Rows - 1, 0)
' .Rows = .Rows + 1
For j = j + 1 To Val(Trim(.TextMatrix(.Rows - 1, 0)))
If .TextMatrix(i, 0) = .TextMatrix(j, 0) Then
.RemoveItem j
Exit Sub
Else
End If
Next j
Next i
Loop
End With
End Sub
最後更新:2017-04-03 15:21:44