梦见别人把蛇砍成两段:对spread的几个操作

来源:百度文库 编辑:偶看新闻 时间:2024/04/29 01:30:04
对spread的几个操作
‘在两个spread表格中复制一行fpdoutmemo->fpdoutmemo2
‘SrcRow源行号
‘DetRow目的行号
Private Sub CopiMemo(SrcRow As Long, DetRow As Long)
Dim i As Integer
With fpdOutmemo2
    If DetRow > .MaxRows Then ‘如果需要复制的行超过目的的最大行
        Exit Sub
    End If
    .Row = DetRow: fpdOutmemo.Row = SrcRow ‘定位行
    For i = 1 To fpdOutmemo.MaxCols ‘复制一行中的每一列
        .Col = i: fpdOutmemo.Col = i
        .Text = fpdOutmemo.Text
    Next i
End WithEnd Sub ‘在fpdOutmemo2表格中插入一行
‘SrcRow源行号
Private Sub InsertMemo(SrcRow As Long)
With fpdOutmemo2
    .MaxRows = .MaxRows + 1 ‘增加一个行
    Call CopiMemo(SrcRow, .MaxRows)
End WithEnd Sub ‘fpdOutmemo2,并不删掉,只是把选择去掉
Private Sub DelMemo2(DetRow As Long)
Dim i As Long
With fpdOutmemo2
   .Col = 1‘选择框
   .Text = 0
End With
End Sub

‘fpdOutmemo2,删除
Private Sub DelMemo3()
Dim i As Long
Dim j As Long
With fpdOutmemo2
j = 0
    For i = i To .MaxRows
        .Col = 1
        .Row = i
        If .Text = 0 Then
            .DeleteRows i, 1‘删除行
            j = j + 1
        End If
    Next i
    .MaxRows = .MaxRows - j‘更新最大行记录数,否则会出现空白行
End With
End Sub ‘查找表格中相同的记录在fpdoutmemo中查找和fpdoutmemo2中相同的记录
Private Function FindMemo2(SrcRow As Long) As Long
Dim strOutMemo As String
Dim strProductid As String
Dim strOutMemo2 As String
Dim strProductid2 As String
Dim i As LongFindMemo2 = 0
With fpdOutmemo2
    If SrcRow > .MaxRows Then
        FindMemo2 = 0 ‘没有找到
        Exit Function
    End If
    .Row = SrcRow
    .Col = INT_FPMEMO_KEY_OUTMEMOID ‘单证号
    strOutMemo = .Text
    .Col = INT_FPMEMO_KEY_PRODUCTID ‘成品号
    strProductid = .Text
    End With
   
    With fpdOutmemo
        If .MaxRows = 0 Then
             FindMemo2 = 0 ‘没有找到
             Exit Function
        End If
        For i = 1 To .MaxRows
            .Row = i
            .Col = INT_FPMEMO_KEY_OUTMEMOID
            strOutMemo2 = .Text
            .Col = INT_FPMEMO_KEY_PRODUCTID
            strProductid2 = .Text
            ‘只有在两条记录的单证号和成品号都相等的情况,才算找到
            If strOutMemo = strOutMemo2 And strProductid = strProductid2 Then
                FindMemo2 = i ‘返回找到的记录的行
                Exit Function
            End If
        Next i
    End With
    End Function