如何在此代码中输出方法'center'的值-Java

时间:2018-11-14 11:13:24

标签: java

Option Explicit

Sub YourProcedureName()
    Dim wsDB As Worksheet
    Set wsDB = ThisWorkbook.Sheets("DataBase")

    Dim wsEmails As Worksheet
    Set wsEmails = ThisWorkbook.Sheets("Emails")

    'm = wsEmails.Range("C7") 'was not used at all

    With wsDB
        Dim NextFreeRow As Long
        NextFreeRow = .Range("A" & .Rows.Count).End(xlUp).Row + 1

        Dim Last_Day As String
        Last_Day = .Range("A" & .Rows.Count).End(xlUp).Value

        Dim Col_Search As Range
        Col_Search = .Range("A3", .Range("A" & .Rows.Count).End(xlUp))

        Dim Col_Contain As Range
        Col_Contain = .Range("G3", .Range("G" & .Rows.Count).End(xlUp))
    End With

    With wsEmails
        wsDB.Cells(NextFreeRow, 7).Value = Application.WorksheetFunction.SumIf(Col_Search, "=" & Last_Day, Col_Contain)
        wsDB.Cells(NextFreeRow, 1).Value = Date
        wsDB.Cells(NextFreeRow, 2) = .Range("C1")
        wsDB.Cells(NextFreeRow, 3) = .Range("C2")
        wsDB.Cells(NextFreeRow, 4) = .Range("C3")
        wsDB.Cells(NextFreeRow, 5) = .Range("C5")
        wsDB.Cells(NextFreeRow, 6) = .Range("C6")
        wsDB.Cells(NextFreeRow, 8) = .Range("C8")
        wsDB.Cells(NextFreeRow, 9) = "=RC[-1]-RC[-2]"
        wsDB.Cells(NextFreeRow, 9).Font.Bold = True
        wsDB.Cells(NextFreeRow, 10) = .Range("C11")
        wsDB.Cells(NextFreeRow, 11) = .Range("C12")
        wsDB.Cells(NextFreeRow, 12) = .Range("C13")
        wsDB.Cells(NextFreeRow, 13) = .Range("C15")
        wsDB.Cells(NextFreeRow, 15) = "=SUM(RC[-5]:RC[-1])"
        wsDB.Cells(NextFreeRow, 15).Font.Bold = True
        wsDB.Cells(NextFreeRow, 16) = Application.WorksheetFunction.VLookup(.Range("C17"), .Range("E18:F19").Value, 2, False)
        wsDB.Cells(NextFreeRow, 17) = Application.WorksheetFunction.VLookup(.Range("C18"), .Range("E18:F19").Value, 2, False)
        wsDB.Cells(NextFreeRow, 18) = Application.WorksheetFunction.VLookup(.Range("C19"), .Range("E18:F19").Value, 2, False)
        wsDB.Cells(NextFreeRow, 19) = Application.WorksheetFunction.VLookup(.Range("C20"), .Range("E18:F19").Value, 2, False)
        wsDB.Cells(NextFreeRow, 20) = Application.WorksheetFunction.VLookup(.Range("C21"), .Range("E18:F19").Value, 2, False)
        wsDB.Cells(NextFreeRow, 21) = "=SUM(RC[-5]:RC[-1])"
        wsDB.Cells(NextFreeRow, 21).Font.Bold = True
        wsDB.Cells(NextFreeRow, 22) = Application.WorksheetFunction.VLookup(.Range("C24"), .Range("E25:F26").Value, 2, False)
        wsDB.Cells(NextFreeRow, 23) = Application.WorksheetFunction.VLookup(.Range("C25"), .Range("E25:F26").Value, 2, False)
        wsDB.Cells(NextFreeRow, 24) = "=SUM(RC[-2]:RC[-1])"
        wsDB.Cells(NextFreeRow, 24).Font.Bold = True
        wsDB.Cells(NextFreeRow, 25) = "=SUM(RC[-16]+RC[-10]+RC[-4]+RC[-1])"
        wsDB.Cells(NextFreeRow, 25).Font.Bold = True
    End With


    Dim TargetColumns As Variant
    TargetColumns = Array(20, 23) 'Column numbers to place into.

    Dim SourceCells As Range
    Set SourceCells = ThisWorkbook.Worksheets("Emails").Range("C22,C26")

    Dim x As Long

    'Look at each cell in turn.
    Dim rCell As Range
    For Each rCell In SourceCells

        'Find the last cell in the correct column.
        Dim rAddToCell As Range
        Set rAddToCell = LastCell(ThisWorkbook.Worksheets("DataBase"), CLng(TargetColumns(x)))

        'If there's already a comment then delete it first
        'Then add value from SourceCell into comment in Target column.
        With rAddToCell
            If HasComment(rAddToCell) Then
                .ClearComments
            End If
            .AddComment
            .Comment.Text Text:=rCell.Value
        End With

        x = x + 1
    Next rCell

End Sub

如何打印“中心”的值?

1 个答案:

答案 0 :(得分:2)

  public static void main(String[] args) {
        Point p1 = new Point(1,5); 
        Point p2 = new Point(3,10);
        Point center = p1.center(p2);
        center.printPoint();
    }
相关问题