MSHFlexGrid 中的列与列之间数据怎样替换呢?   如 A 列123  B列456  这里,要替换24。那么,结果为 A列为134, B列为 562 这样的。

解决方案 »

  1.   

    Private Sub Form_Load()
        With MSFlexGrid1
            .Row = 1
            .Col = 1
            .Text = "524312"
            .Col = 2
            .Text = "dfd3333"
            .Col = 3
            .Text = "euui33"
        End WithEnd SubPrivate Sub Command1_Click()
        Dim strA As String
        Dim strB As String
        Dim strC As String    Dim strR(3) As String
        Dim intS(3) As Integer
        Dim strT As String
        Dim i As Integer
        Dim j As Integer
        strA = "2"
        strB = "4"
        strC = "d"
        With MSFlexGrid1
            .Row = 1        For j = 1 To 3
                .Col = j
                intS(j - 1) = Len(.Text)
            Next j        For j = 1 To 3
            .Col = j
                For i = 1 To Len(.Text)
                    If Mid(.Text, i, 1) = strA Then
                        .Text = Left(.Text, i - 1) & Mid(.Text, i + 1, Len(.Text))
                        strR(j - 1) = strA
                        Exit For
                    ElseIf Mid(.Text, i, 1) = strB Then
                        .Text = Left(.Text, i - 1) & Mid(.Text, i + 1, Len(.Text))
                         strR(j - 1) = strB
                        Exit For
                    ElseIf Mid(.Text, i, 1) = strC Then
                        .Text = Left(.Text, i - 1) & Mid(.Text, i + 1, Len(.Text))
                         strR(j - 1) = strC
                        Exit For
                    End If
                Next i
            Next j        For j = 1 To 3
                .Col = j
                .Text = .Text & strR(IIf(j = 3, 0, j))
            Next j        
            For j = 3 To 1 Step -1
                .Col = j
                If Len(.Text) > intS(j - 1) Then
                    strT = Left(.Text, Len(.Text) - intS(j - 1))
                    .Text = Mid(.Text, Len(strT) + 1, Len(.Text))
                    .Col = IIf(j = 1, 3, j - 1)
                    .Text = .Text & strT
                End If
            Next j
        End WithEnd Sub
      

  2.   


    上面写错了, MSHFlexgrid的 ABC列中 C列的一个数移动至B列 B烈的一个数移动至 A列,A列的一个数移动至C列里。  就是这样的。 应该是数据循环,不是替换了