我目前只学了存储后结果数据添加的方法,我想了解怎样一个字段内一行一行地添加完成记录问题。 
  还有怎样一个字段内数据输入操作完成后,又让可以其字段的内容后面又反复添加操作呢 如 
155 
424 
846 
255 
382 
491 

6  这是一个字段内三次添加的结果,14823456添加完成后,又添加524589,又添加546521,需要添加时用这种方法添加。 
    这个方式怎么做呢

解决方案 »

  1.   

    还有怎样一个字段内数据输入操作完成后,又让可以其字段的内容后面又反复添加操作呢 
    ---------------
    比如:
    update tb set 字段名称=值 where 主键=123
      

  2.   

    text1 指定一列填入一列
    由左到右Private Sub Command1_Click()
        Dim cn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
        Dim i As Integer
        Dim intCount As Integer
        Dim intEndRow As Integer    cn.CursorLocation = adUseClient
        cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\mydb.mdb;Persist Security Info=False"
        
        rs.Open "select * from mytable", cn, adOpenStatic, adLockOptimistic
        
        
        If rs.RecordCount > 0 Then
            While Not rs.EOF
                For i = rs.Fields.Count - 1 To 0 Step -1
                    If rs.Fields(i) <> Null Or rs.Fields(i) <> "" Then
                        If i > intCount Then
                            intCount = i
                        End If
                        Exit For
                    End If
                Next i
                rs.MoveNext
            Wend
            
            rs.MoveFirst
        End If
        
        intCount = intCount + 1
        
        With MSFlexGrid1
            .Col = Text1.Text   'Text2指定要填入的列
            
            For i = .Rows - 1 To 1 Step -1
                .Row = i
                
                If Trim(.Text) <> "" Then
                    intEndRow = i
                    Exit For
                End If
            Next i
            
            If intEndRow > 0 Then
                For i = 1 To intEndRow
                    .Row = i
                    
                    If rs.EOF Then
                        rs.AddNew
                        rs.Fields(0) = i
                        rs.Fields(intCount) = .Text
                        rs.Update
                    Else
                        rs.Fields(intCount) = .Text
                        rs.Update
                    End If
                    
                    rs.MoveNext
                Next i
            End If
        End With
        
        
        rs.Close
        cn.Close
        Set rs = Nothing
        Set cn = NothingEnd SubPrivate Sub Form_Load()
        Dim TextLine
        Dim strFileName As String
        Dim a() As String
        Dim i As Integer
        Dim j As Integer
        With MSFlexGrid1
            .Rows = 20
            .Cols = 6        strFileName = App.Path & "\testdata2.txt"        Open strFileName For Input As #1 ' 打开文件。        Do While Not EOF(1) ' 循环至文件尾。
                Line Input #1, TextLine ' 读入一行数据并将其赋予某变量。
                i = i + 1
                .Row = i
                For j = 1 To Len(TextLine)
                    .Col = j
                    .Text = Mid(TextLine, j, 1)
                Next j        Loop        Close #1 ' 关闭文件。
        End WithEnd Sub
      

  3.   

    Private Sub Command1_Click()
        Dim cn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
        Dim i As Integer
        Dim intCount As Integer
        Dim intEndRow As Integer    cn.CursorLocation = adUseClient
        cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\mydb.mdb;Persist Security Info=False"
        
        rs.Open "select * from mytable", cn, adOpenStatic, adLockOptimistic
        
        
        If rs.RecordCount > 0 Then
            While Not rs.EOF
                For i = rs.Fields.Count - 1 To 0 Step -1
                    If Len(rs.Fields(1)) > intCount Then
                        intCount = Len(rs.Fields(1))
                    End If
                Next i
                rs.MoveNext
            Wend
            
            rs.MoveFirst
        End If
        
    '    intCount = intCount + 1
        
        With MSFlexGrid1
            .Col = Text2.Text   'Text2指定要填入的列
            
            For i = .Rows - 1 To 1 Step -1
                .Row = i
                
                If Trim(.Text) <> "" Then
                    intEndRow = i
                    Exit For
                End If
            Next i
            
            If intEndRow > 0 Then
                For i = 1 To intEndRow
                    .Row = i
                    
                    If rs.EOF Then
                        rs.AddNew
                        rs.Fields(0) = i
                        rs.Fields(1) = .Text
                        rs.Update
                    Else
                        rs.Fields(1) = rs.Fields(1) & Space(intCount - Len(rs.Fields(1))) & .Text
                        rs.Update
                    End If
                    
                    rs.MoveNext
                Next i
            End If
        End With
        
        
        rs.Close
        cn.Close
        Set rs = Nothing
        Set cn = NothingEnd SubPrivate Sub Form_Load()
        Dim TextLine
        Dim strFileName As String
        Dim a() As String
        Dim i As Integer
        Dim j As Integer
        With MSFlexGrid1
            .Rows = 20
            .Cols = 6        strFileName = App.Path & "\testdata2.txt"        Open strFileName For Input As #1 ' 打开文件。        Do While Not EOF(1) ' 循环至文件尾。
                Line Input #1, TextLine ' 读入一行数据并将其赋予某变量。
                i = i + 1
                .Row = i
                For j = 1 To Len(TextLine)
                    .Col = j
                    .Text = Mid(TextLine, j, 1)
                Next j        Loop        Close #1 ' 关闭文件。
        End WithEnd Sub
      

  4.   

    Private Sub Command1_Click()
        Dim cn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
        Dim i As Integer
        Dim intCount As Integer
        Dim intEndRow As Integer    cn.CursorLocation = adUseClient
        cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\mydb.mdb;Persist Security Info=False"
        
        rs.Open "select * from mytable", cn, adOpenStatic, adLockOptimistic
        
        
        If rs.RecordCount > 0 Then
            While Not rs.EOF
                For i = rs.Fields.Count - 1 To 0 Step -1
                    If Len(rs.Fields(1)) > intCount Then
                        intCount = Len(rs.Fields(1))
                    End If
                Next i
                rs.MoveNext
            Wend
            
            rs.MoveFirst
        End If
        
    '    intCount = intCount + 1
        
        With MSFlexGrid1
            .Col = Text2.Text   'Text2指定要填入的列
            
            For i = .Rows - 1 To 1 Step -1
                .Row = i
                
                If Trim(.Text) <> "" Then
                    intEndRow = i
                    Exit For
                End If
            Next i
            
            If intEndRow > 0 Then
                For i = 1 To intEndRow
                    .Row = i
                    
                    If rs.EOF Then
                        rs.AddNew
                        rs.Fields(0) = i
                        rs.Fields(1) = Space(intCount) & .Text
                        rs.Update
                    Else
                        rs.Fields(1) = rs.Fields(1) & Space(intCount - Len(rs.Fields(1))) & .Text
                        rs.Update
                    End If
                    
                    rs.MoveNext
                Next i
            End If
        End With
        
        
        rs.Close
        cn.Close
        Set rs = Nothing
        Set cn = NothingEnd SubPrivate Sub Form_Load()
        Dim TextLine
        Dim strFileName As String
        Dim a() As String
        Dim i As Integer
        Dim j As Integer
        With MSFlexGrid1
            .Rows = 20
            .Cols = 6        strFileName = App.Path & "\testdata2.txt"        Open strFileName For Input As #1 ' 打开文件。        Do While Not EOF(1) ' 循环至文件尾。
                Line Input #1, TextLine ' 读入一行数据并将其赋予某变量。
                i = i + 1
                .Row = i
                For j = 1 To Len(TextLine)
                    .Col = j
                    .Text = Mid(TextLine, j, 1)
                Next j        Loop        Close #1 ' 关闭文件。
        End WithEnd Sub
      

  5.   

    Private Sub Command1_Click()
        Dim cn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
        Dim i As Integer
        Dim intCount As Integer
        Dim intEndRow As Integer    cn.CursorLocation = adUseClient
        cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\mydb.mdb;Persist Security Info=False"
        
        rs.Open "select * from mytable", cn, adOpenStatic, adLockOptimistic
        
        
        If rs.RecordCount > 0 Then
            While Not rs.EOF
                For i = rs.Fields.Count - 1 To 0 Step -1
                    If Len(rs.Fields(1)) > intCount Then
                        intCount = Len(rs.Fields(1))
                    End If
                Next i
                rs.MoveNext
            Wend
            
            rs.MoveFirst
        End If
        
    '    intCount = intCount + 1
        
        With MSFlexGrid1
            .Col = Text2.Text   'Text2指定要填入的列
            
            For i = .Rows - 1 To 1 Step -1
                .Row = i
                
                If Trim(.Text) <> "" Then
                    intEndRow = i
                    Exit For
                End If
            Next i
            
            If intEndRow > 0 Then
                For i = 1 To intEndRow
                    .Row = i
                    
                    If .Text = Text1.Text Then
                        For m = i + 1 To intEndRow
                            .Row = m
                            If rs.EOF Then
                                rs.AddNew
                                rs.Fields(0) = m - i
                                rs.Fields(1) = Space(intCount) & .Text
                                rs.Update
                            Else
                                rs.Fields(1) = rs.Fields(1) & Space(intCount - Len(rs.Fields(1))) & .Text
                                rs.Update
                            End If
                            
                            rs.MoveNext
                        Next m
                    End If
                Next i
            End If
        End With
        
        
        rs.Close
        cn.Close
        Set rs = Nothing
        Set cn = NothingEnd SubPrivate Sub Form_Load()
        Dim TextLine
        Dim strFileName As String
        Dim a() As String
        Dim i As Integer
        Dim j As Integer
        With MSFlexGrid1
            .Rows = 20
            .Cols = 6        strFileName = App.Path & "\testdata2.txt"        Open strFileName For Input As #1 ' 打开文件。        Do While Not EOF(1) ' 循环至文件尾。
                Line Input #1, TextLine ' 读入一行数据并将其赋予某变量。
                i = i + 1
                .Row = i
                For j = 1 To Len(TextLine)
                    .Col = j
                    .Text = Mid(TextLine, j, 1)
                Next j        Loop        Close #1 ' 关闭文件。
        End WithEnd Sub
      

  6.   

    Private Sub Command1_Click()
        Dim cn As New ADODB.Connection
        Dim rs As New ADODB.Recordset
        Dim i As Integer
        Dim intCount As Integer
        Dim intEndRow As Integer
        Dim intStart As Integer    cn.CursorLocation = adUseClient
        cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\mydb.mdb;Persist Security Info=False"
        
        rs.Open "select * from mytable", cn, adOpenStatic, adLockOptimistic
        
        
        If rs.RecordCount > 0 Then
            While Not rs.EOF
                For i = rs.Fields.Count - 1 To 0 Step -1
                    If Len(rs.Fields(1)) > intCount Then
                        intCount = Len(rs.Fields(1))
                    End If
                Next i
                rs.MoveNext
            Wend
            
            rs.MoveFirst
        End If
        
    '    intCount = intCount + 1
        
        With MSFlexGrid1
            .Col = Text2.Text   'Text2指定要填入的列
            
            For i = .Rows - 1 To 1 Step -1
                .Row = i
                
                If Trim(.Text) <> "" Then
                    intEndRow = i
                    Exit For
                End If
            Next i
            
            If intEndRow > 0 Then
                intStart = fun_get_location(Text2.Text)
                
                If intStart > 0 Then
                    For m = intStart To intEndRow
                        .Row = m
                        If rs.EOF Then
                            rs.AddNew
                            rs.Fields(0) = m - i
                            rs.Fields(1) = Space(intCount) & .Text
                            rs.Update
                        Else
                            rs.Fields(1) = rs.Fields(1) & Space(intCount - Len(rs.Fields(1))) & .Text
                            rs.Update
                        End If
                        
                        rs.MoveNext
                    Next m
                End If
            End If
        End With
        
        
        rs.Close
        cn.Close
        Set rs = Nothing
        Set cn = NothingEnd SubPrivate Function fun_get_location(ByVal intCol As Integer) As Integer
        Dim i As Integer
        
        For i = 1 To MSFlexGrid1.Rows - 1
            Data = Data & MSFlexGrid1.TextMatrix(i, intCol)
        Next i
        
        If InStr(1, Data, Text1.Text) > 0 Then
            fun_get_location = InStr(1, Data, Text1.Text) + Len(Text1.Text)
        Else
            fun_get_location = 0
        End If
    End FunctionPrivate Sub Form_Load()
        Dim TextLine
        Dim strFileName As String
        Dim a() As String
        Dim i As Integer
        Dim j As Integer
        With MSFlexGrid1
            .Rows = 20
            .Cols = 6        strFileName = App.Path & "\testdata2.txt"        Open strFileName For Input As #1 ' 打开文件。        Do While Not EOF(1) ' 循环至文件尾。
                Line Input #1, TextLine ' 读入一行数据并将其赋予某变量。
                i = i + 1
                .Row = i
                For j = 1 To Len(TextLine)
                    .Col = j
                    .Text = Mid(TextLine, j, 1)
                Next j        Loop        Close #1 ' 关闭文件。
        End WithEnd Sub