Dim t As Table = CurrentTable
If t.Cols(t.ColSel).IsString Then ’字符列,本例填充的是字符序列,所以要先判断列类型是否字符列,如果是日期类型或数字类型,再作相应判断。
Dim s As String = t.Rows(t.TopPosition)(t.Cols(t.ColSel)) '例如:"KJ150522T55-06"
Dim cnt As Integer = s.Split("-")(1).Length ‘这样,尾数可以是任意位数,而不是局限于两位数。
For i As Integer = t.TopPosition + 1 To t.BottomPosition
If i < t.TopPosition + Val(s.Split("-")(1)) Then ’在选择行过多时,避免出现小于1的情况。
t.Rows(i)(t.Cols(t.ColSel)) = t.Rows(i - 1)(t.Cols(t.ColSel)).Split("-")(0) & "-" & CStr(Val(t.Rows(i - 1)(t.Cols(t.ColSel)).Split("-")(1)) - 1).PadLeft(cnt,"0") ‘逐行递减。
End If
Next
End If
[此贴子已经被作者于2015/6/8 8:13:57编辑过]