Private Sub Command2_Click()
    If Label2.Caption = " " Then
        Label2.Caption = Text1.Text
    Else
    Static k As Integer
        k = k + 1
        If k = 1 Then
            FG1.TextMatrix(1, 1) = Format(Text1 - Label2.Caption, "00.00")
        ElseIf k = 2 Then
            Label2.Caption = Text1.Text
        ElseIf k = 3 Then
            FG1.TextMatrix(1, 2) = Format(Text1 - Label2.Caption, "00.00")
        ElseIf k = 4 Then
            Label2.Caption = Text1.Text
        ElseIf k = 5 Then
            FG1.TextMatrix(2, 1) = Format(Text1 - Label2.Caption, "00.00")
        ElseIf k = 6 Then
            Label2.Caption = Text1.Text
        ElseIf k = 7 Then
            FG1.TextMatrix(2, 2) = Format(Text1 - Label2.Caption, "00.00")


        End If
    End If
共25行2列 请高手指教!!!

解决方案 »

  1.   

    Static k As Integer
    Static i As Integer
    Static j As Integer
    k=k+1
    if k mod 2 = 0 then
        Label2.Caption = Text1.Text 
    else
        if i=0 then
            i=i+1
        end if
        if j=0 or j=1 then
            j=j+1
        elseif j=2 then
            i=i+1
            j=1
        end if
        FG1.TextMatrix(i, j) = Format(Text1 - Label2.Caption, "00.00") 
    end if
      

  2.   

    Private Sub Command2_Click()
        If Label2.Caption = " " Then
            Label2.Caption = Text1.Text
        Else
        Static k As Integer
            k = k + 1
            If k Mod 2 = 0 Then 'k是2的倍数(k是偶数)
               Label2.Caption = Text1.Text
            Else
               'k是奇数
               If (k + 1) Mod 4 = 0 Then 'k为 3,7,11,15,19...
                   FG1.TextMatrix((k + 1) / 4, 2) = Format(Text1 - Label2.Caption, "00.00")
               End If
               If (k + 3) Mod 4 = 0 Then 'k为 1,5,9,13,17...
                  FG1.TextMatrix((k + 3) / 4, 1) = Format(Text1 - Label2.Caption, "00.00")
               End If
            End If
            
            'If k = 1 Then
            '    FG1.TextMatrix(1, 1) = Format(Text1 - Label2.Caption, "00.00")
            'ElseIf k = 2 Then
            '    Label2.Caption = Text1.Text
            'ElseIf k = 3 Then
            '    FG1.TextMatrix(1, 2) = Format(Text1 - Label2.Caption, "00.00")
            'ElseIf k = 4 Then
            '    Label2.Caption = Text1.Text
            'ElseIf k = 5 Then
             '   FG1.TextMatrix(2, 1) = Format(Text1 - Label2.Caption, "00.00")
            'ElseIf k = 6 Then
             '   Label2.Caption = Text1.Text
            'ElseIf k = 7 Then
            '    FG1.TextMatrix(2, 2) = Format(Text1 - Label2.Caption, "00.00")
            '......
            '......        'End If
        End If
    End Sub