(1)标准模块自定义函数Public Function RemoveDoubleItemFormMsg(ByVal msg As MSFlexGrid) As Boolean On Error GoTo 0 Dim i As Long, j As Long, k As Long
With msg aa: If .Rows = 2 Then Exit Function For i = 1 To .Rows - 2 For j = i + 1 To .Rows - 1 For k = 0 To .Cols - 1 If .TextMatrix(i, k) <> .TextMatrix(j, k) Then GoTo bb Next .RemoveItem j GoTo aa bb: Next Next End With
End Function (2)窗体中引用示例:Private Sub Form_Load()
Dim i As Long, j As Long With msg1 .Cols = 5 .Rows = 5 .FixedCols = 0 .FixedRows = 1 For i = 1 To 4 For j = 0 To 4 .TextMatrix(i, j) = i + j Next Next .Rows = .Rows + 2 For i = 0 To 4 .TextMatrix(.Rows - 2, i) = .TextMatrix(3, i) .TextMatrix(.Rows - 1, i) = .TextMatrix(2, i) Next End With
End Sub Private Sub msg1_DblClick() RemoveDoubleItemFormMsg msg1 End Sub
(1)标准模块自定义函数Public Function RemoveDoubleItemFormMsg(ByVal msg As MSFlexGrid) As Boolean
On Error GoTo 0 Dim i As Long, j As Long, k As Long
With msg
aa:
If .Rows = 2 Then Exit Function
For i = 1 To .Rows - 2
For j = i + 1 To .Rows - 1
For k = 0 To .Cols - 1
If .TextMatrix(i, k) <> .TextMatrix(j, k) Then GoTo bb
Next
.RemoveItem j
GoTo aa
bb:
Next
Next
End With
End Function
(2)窗体中引用示例:Private Sub Form_Load()
Dim i As Long, j As Long
With msg1
.Cols = 5
.Rows = 5
.FixedCols = 0
.FixedRows = 1
For i = 1 To 4
For j = 0 To 4
.TextMatrix(i, j) = i + j
Next
Next
.Rows = .Rows + 2
For i = 0 To 4
.TextMatrix(.Rows - 2, i) = .TextMatrix(3, i)
.TextMatrix(.Rows - 1, i) = .TextMatrix(2, i)
Next
End With
End Sub
Private Sub msg1_DblClick()
RemoveDoubleItemFormMsg msg1
End Sub