根据另一列填充vsfgird的一列

Fill one column of vsfgird according to another column

我有一个 vsflexgrid,它由这样的数据填充:

ID - Name - Rate - Gift
100- jack -  2   -   
101- Mark -  6   -   
102- peter - 10  -   

我想计算每行的倍率并以此填充礼物列。 例如 : 如果 rate = 0 且 rate <5 那么 礼物=0

我使用此代码但仅适用于第一行: 礼品栏按栏目Rate

填写
 dim i,Numrate , Numgift as integer
    For i = 1 To VSF(3).Rows - 1
    Numrate = VSF(3).TextMatrix(i, 3)
    Numgift = VSF(3).TextMatrix(i, 4)
    If Numrate = 0 And Numrate < 5 Then
    Numgift = 0
    ElseIf Numrate >= 5 And Numrate < 9 Then
    Numgift = 1
    ElseIf Numrate >= 10 And Numrate < 14 Then
    Numgift = 1 = 2
    ElseIf Numrate >= 15 And Numrate < 19 Then
    Numgift = 1 = 3
    ElseIf Numrate >= 20 And Numrate < 24 Then
    Numgift = 1 = 4
    End If
    Next i

结果应该是:

ID - Name - Rate - Gift
100- jack -  2   -   0 
101- Mark -  6   -   1
102- peter - 10  -   2
Dim i As Integer, NumRate As Integer, Numgift As Integer
For i = 1 To VSF(3).Rows - 1
    Numrate = VSF(3).TextMatrix(i, 3)
    Select Case Numrate
        Case 0 To 5
            Numgift = 0
        Case 6 To 9
            Numgift = 1
        Case 10 To 14
            Numgift = 2
        Case 15 To 19
            Numgift = 3
        Case 20 To 24
            Numgift = 4
    End Select
    VSF(3).TextMatrix(i, 4) = Numgift
Next i