Option Explicit
    Dim sum As Integer
    Dim j As Integer
Private Sub Form_Load()
    Text1 = ""
    vSFlexGrid1.Cols = 16
End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 And Text1 <> "" Then
        If j < 30 Then
            vSFlexGrid1.TextMatrix(j + 1, sum + 1) = Text1
            sum = sum + 1
            If (sum + 1) Mod 15 = 0 Then
                j = j + 1
                vSFlexGrid1.Rows = j + 2
                sum = sum - 15 + 1
            End If
        End If
    End If
End Sub
假如我正输入第2行3列的数据 发现错了 想把第二行清空 重新输入 该这么做呢?

解决方案 »

  1.   

    LZ:输入数据时通过消息提醒核对,确认输入无误.但速度会慢下来.Option Explicit
        Dim sum As Integer
        Dim j As Integer
    Private Sub Form_Load()
        Text1 = ""
        MSFlexGrid1.Cols = 16
    End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = 13 And Text1 <> "" Then
            If j < 30 Then
                Dim Msg, Style, Title, Help, Ctxt, Response, MyString
                Msg = "Do you want to continue ?"   ' 定义信息。
                Style = vbYesNo + vbCritical + vbDefaultButton1   ' 定义按钮。
                Title = "MsgBox Demonstration"   ' 定义标题。
                Help = "DEMO.HLP"   ' 定义帮助文件。
                Ctxt = 1000   ' 定义标题
                      ' 上下文。
                      ' 显示信息。
                Response = MsgBox(Msg, Style, Title, Help, Ctxt)
                If Response = vbYes Then   ' 用户按下“是”。
                    MyString = "Yes"   ' 完成某操作。
                    MSFlexGrid1.TextMatrix(j + 1, sum + 1) = Text1
                    sum = sum + 1
                    Text1 = ""
                If (sum + 1) Mod 15 = 0 Then
                    j = j + 1
                    MSFlexGrid1.Rows = j + 2
                    sum = sum - 15 + 1
                End If
                Else   ' 用户按下“否”。
                   MyString = "No"   ' 完成某操作。
                   Exit Sub
                End If
            End If
        End If
    End Sub
      

  2.   

    Option Explicit
        Dim sum As Integer
        Dim j As IntegerPrivate Sub Command1_Click() '修改
        Dim hang As Integer
        Dim lie As Integer
        hang = Val(Text2)
        lie = Val(Text3)
        MSFlexGrid1.TextMatrix(hang, lie) = Text4
    End SubPrivate Sub Form_Load()
        Text1 = ""
        Text2 = ""
        Text3 = ""
        Text4 = ""
        MSFlexGrid1.Cols = 16
    End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = 13 And Text1 <> "" Then
            If j < 30 Then
                MSFlexGrid1.TextMatrix(j + 1, sum + 1) = Text1
                sum = sum + 1
                Text1 = ""
                If (sum + 1) Mod 15 = 0 Then
                    j = j + 1
                    MSFlexGrid1.Rows = j + 2
                    sum = sum - 15 + 1
                End If
            End If
        End If
    End Sub
      

  3.   

    1楼的看不明白
    2楼 我想通过用鼠标点某行后 按command1来重新输入某行的数据 可以吗
    另外  hang = Val(Text2)
         lie = Val(Text3)
         vSFlexGrid1.TextMatrix(hang, lie) = Text4
    不理解  
      

  4.   

    3楼我写错了 应该是 我想通过用鼠标点某行后 按command1来重清除某行的数据 然后在通过Text1_KeyPress事件来新输入某行的数据 可以吗 ?
      

  5.   

    LZ:没有程序是万能的。
    我3楼处的代码,hang是行,lie是列,通过对指定行列由Text4输入的正确数据来替换错误数据。