# Re: 那!结果是否可行? 有ㄚ...

Posted by sendy on September 05, 1998 at 10:59:16:

In Reply to: 那!结果是否可行 posted by Gary Chen on September 01, 1998 at 18:02:02:

有的!!这段程式码要写在
Private Sub DBGrid_UnboundReadData(ByVal RowBuf As MSDBGrid.RowBuffer, StartLocation As Variant, ByVal ReadPriorRows As Boolean)
Dim incr As Integer
Dim curRow As Integer
Dim maxrow As Integer
Dim i As Integer
Dim sql As String
Dim snpTmp As Recordset

sql = "SELECT COST_NO, COST_ITEM, AMT FROM BASIC_COST"
sql = sql & " WHERE COST_TYPE = '注册费'"
Set snpTmp = gdbEdu.OpenRecordset(sql, dbOpenSnapshot)
If snpTmp.BOF And snpTmp.EOF Then Exit Sub
snpTmp.MoveLast
maxrow = snpTmp.RecordCount
If ReadPriorRows Then
incr = -1 ' 往前读取
Else
incr = 1 ' 往后读取
End If

If IsNull(StartLocation) Then
If ReadPriorRows Then
curRow = maxrow - 1 ' Reading data from the last row
Else
curRow = 0 ' Reading data from the first row
End If
Else
curRow = Val(StartLocation) + incr
End If
i = 0
snpTmp.MoveFirst
Do While Not snpTmp.EOF
RowBuf.Value(i, S_COST_ITEM) = snpTmp!COST_ITEM
RowBuf.Value(i, S_COST_AMT) = snpTmp!amt
RowBuf.Value(i, S_COST_NO) = snpTmp!cost_No
RowBuf.Bookmark(i) = curRow
curRow = curRow + incr
i = i + 1
snpTmp.MoveNext
Loop
snpTmp.Close
RowBuf.RowCount = i
mnMaxRow = i
End Sub

这是小妹上www.apex.com这个站,download一关于dbgrid 用法的范例,再根据自己需求改的, 虽然已可行,但对于这个
sub中参数的由来仍不甚清楚,如果你想要这个范例档,我可以mail给你.....

Follow Ups:

- Re: 那!结果是否可行? 有ㄚ... Gary chen 11:35:35 9/09/98 (0)
- Re: 那!结果是否可行? 有ㄚ... xxkuo 22:45:59 9/07/98 (0)