0

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

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

我想为每一行计算多个费率并以此填充礼品列。例如:如果 rate = 0 并且 rate <5 那么 Gift=0

我使用此代码,但仅适用于第一行:根据列费率填充的礼品列

 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
4

1 回答 1

1
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
于 2017-05-08T20:30:54.327 回答