编译错误byref参数类型不匹配

时间:2017-06-26 18:00:05

标签: vba excel-vba compilation pass-by-reference excel

我在传递ByRef变量方面经验丰富。我知道我必须在调用和调用过程中声明它们(并且作为相同类型的过程)。我做到了,但仍然遇到编译错误。

这是失败的电话:

transition = reply_manager(CommentfirstJSON, a_b_c_d) 

标记变量a_b_c_d。它是一个String,被调用的函数需要一个String。那我做错了什么?

Function comment_manager(ByVal CommentJSON As Object, ByRef defects_of_cat As Dictionary)
    Dim CommentobjJSON As Object
    Dim comment_date As Date
    Dim comment_statusJSON As Object
    Dim comment_Closed As Boolean
    Dim comment_author, comment_author_displayname As String
    Dim comment_severity As String
    Dim comment_status_ask_answer_fix_reject As String
    Dim comment_resolvedFriendlyDate As Date
    Dim comment_resolvedUser As String
    Dim a_b_c_d, abcd As String
    Dim red_blue_amber_green As String
    Dim comment_avatarURL As String
    Dim comment_resolved_by_dangling As Boolean
    Dim comment_resolved_user As String
    Dim resolved_type As String
    Dim writen_lines_this_comment As Integer

    writen_lines_this_comment = 0

    comment_author = CommentJSON.authorUserName
    comment_author_displayname = CommentJSON.authorDisplayName

    comment_avatarURL = CommentJSON.authorAvatarUrl
    Call register_avatar(comment_author, site_URL & comment_avatarURL)
    Call register_avatar(comment_author_displayname, site_URL & comment_avatarURL)

    comment_original = CommentJSON.body

    comment_original = Replace(comment_original, "<p>", "")

    a_b_c_d = "D" ' default if author cannot be bothered to classify then its probably not important

        If InStr(Left(comment_original, 1), "A") > 0 Then a_b_c_d = "A"
        If InStr(Left(comment_original, 1), "B") > 0 Then a_b_c_d = "B"
        If InStr(Left(comment_original, 1), "C") > 0 Then a_b_c_d = "C"

        'If InStr(Left(comment_original, 1), "D") > 0 Then a_b_c_d = "D"

        comment_target = CommentJSON.originalSelection
        comment_id = CommentJSON.id
        comment_date = date_convert_to_date(CommentJSON.lastModificationDate)

        comment_URL = base_URL & CommentJSON.commentDateUrl

        Set comment_statusJSON = GetObjectProperty(CommentJSON, "resolveProperties")

        'comment_avatarURL = CommentJSON.authorAvatarUrl

        comment_Closed = comment_statusJSON.resolved

        If comment_Closed Then

            comment_resolvedFriendlyDate = date_convert_to_date(comment_statusJSON.resolvedFriendlyDate)

            comment_resolvedUser = comment_statusJSON.resolvedUser

            'comment_avatarURL = comment_resolvedUser

            comment_resolved_by_dangling = comment_statusJSON.resolvedByDangling

            red_blue_amber_green = "Green"

            If comment_resolved_by_dangling Then red_blue_amber_green = "Pink"

        Else

            red_blue_amber_green = "Red"

        End If

        If red_blue_amber_green = "Pink" Then

            Call writeline("", 0, 0, CDate("01-01-2066"), CDate("01-01-2066"), "", "", comment_date, "Green", "", a_b_c_d, comment_original, comment_target, comment_URL, site_URL & comment_avatarURL)  'The comment birth
            writen_lines_this_comment = writen_lines_this_comment + 1
        Else

            Call writeline("", 0, 0, CDate("01-01-2066"), CDate("01-01-2066"), "", "", comment_date, red_blue_amber_green, "", a_b_c_d, comment_original, comment_target, comment_URL, site_URL & comment_avatarURL)  'The comment birth
            writen_lines_this_comment = writen_lines_this_comment + 1
        End If

    httprequest = "https://csc-ejendom.atlassian.net/wiki/rest/inlinecomments/1.0/comments/" & comment_id & "/replies"

    ask_confluence

    Set CommentobjJSON = TestJSONParsingWithVBACallByName()

    Dim length As Integer
    length = GetProperty(CommentobjJSON, "length")

    For reply_no = 1 To length

        'Dim firstJSON As Object
        Set CommentfirstJSON = GetAtIndex(CommentobjJSON, reply_no - 1)

    '  Dim keys() As String
    '  keys = GetKeys(firstJSON)

        transition = reply_manager(CommentfirstJSON, a_b_c_d)

        writen_lines_this_comment = writen_lines_this_comment + 1

            If transition <> "NO_TRANSITION" Then comment_status_ask_answer_fix_reject = transition

            If red_blue_amber_green <> "Green" Then

                If comment_status_ask_answer_fix_reject = "FIX" Then red_blue_amber_green = "Amber"

                If comment_status_ask_answer_fix_reject = "REJECT" Or comment_status_ask_answer_fix_reject = "ANSWER" Then red_blue_amber_green = "Red"

                If comment_status_ask_answer_fix_reject = "ASK" Then red_blue_amber_green = "Blue"

            End If

    Next reply_no

    If a_b_c_d <> "X" Then

        If comment_Closed Then

            resolved_type = "Resolved"

            If comment_resolved_by_dangling Then resolved_type = "Resolved by dangling"

            Call writeline("", 0, 0, CDate("01-01-2066"), CDate("01-01-2066"), "", "", comment_resolvedFriendlyDate, resolved_type, "", "", "", "", "", comment_resolvedUser) 'gigi

            writen_lines_this_comment = writen_lines_this_comment + 1

            defects_of_cat(a_b_c_d & red_blue_amber_green) = defects_of_cat(a_b_c_d & red_blue_amber_green) + 1

        End If

        Call writeline("", 0, 0, CDate("01-01-2066"), CDate("01-01-2066"), "endofreplies", "", CDate("01-01-2066"), "", "", "", "", "", "", "") 'gigi

    Else

        rollback (writen_lines_this_comment)

    End If

End Function

Function reply_manager(ByVal ReplyJSON As Object, ByRef ab_cd As String) As String
    Dim reply_date As Date
    Dim reply_author_display_name, reply_author_user_name, reply_author_avatar_url, reply_author, reply_text, passed_abcd  As String

    reply_author_display_name = ReplyJSON.authorDisplayName
    reply_author_user_name = ReplyJSON.authorUserName
    reply_author_avatar_url = ReplyJSON.authorAvatarUrl

    Call register_avatar(reply_author_display_name, site_URL & reply_author_avatar_url)
    Call register_avatar(reply_author_user_name, site_URL & reply_author_avatar_url)

    reply_text = ReplyJSON.body
    reply_text = Replace(reply_text, "<p>", "")

    reply_date = date_convert_to_date(ReplyJSON.lastModificationDate)

    reply_manager = "NO_TRANSITION"

    If InStr(Left(reply_text, 3), "FIX") > 0 Then reply_manager = "FIX"
    If InStr(Left(reply_text, 3), "ASK") > 0 Then

    reply_manager = "ASK"

    End If
    If InStr(Left(reply_text, 6), "REJECT") > 0 Then reply_manager = "REJECT"
    If InStr(Left(reply_text, 6), "ANSWER") > 0 Then reply_manager = "ANSWER"

    passed_abcd = ab_cd

    If InStr(Left(reply_text, 2), "A ") > 0 And InStr(Left(reply_text, 2), "AN") = 0 And InStr(Left(reply_text, 2), "AS") = 0 Then ab_cd = "A"
    If InStr(Left(reply_text, 2), "B ") > 0 Or InStr(Left(reply_text, 2), "B:") > 0 Then ab_cd = "B"
    If InStr(Left(reply_text, 2), "C ") > 0 Or InStr(Left(reply_text, 2), "C:") > 0 Then ab_cd = "C"
    If InStr(Left(reply_text, 2), "D ") > 0 Or InStr(Left(reply_text, 2), "D:") > 0 Then ab_cd = "D"
    If InStr(Left(comment_original, 1), "X") > 0 Then a_b_c_d = "X"

    If passed_abcd <> ab_cd Then

        passed_abcd = ab_cd

    Else

        passed_abcd = ""

    End If

    reply_text = "9  " & reply_text

    Call writeline("", 0, 0, CDate("01-05-2066"), CDate("01-05-2066"), "", "", reply_date, reply_manager, "", passed_abcd, reply_text, "", "", site_URL & reply_author_avatar_url) 'gigi

End Function

1 个答案:

答案 0 :(得分:1)

问题在于您认为已将其声明为<div class="flex-container"> <div class="flex-item">flex item 1</div> <div class="flex-item">flex item 1</div> <div class="flex-item">flex item 2</div> <div class="flex-item">flex item 3</div> </div>

String

与VB.Net不同,其中两个都将被声明为Dim a_b_c_d, abcd As String ,在VBA中只有第二个,即String将被声明为abcd。第一个即String将被声明为a_b_c_d

您必须明确声明两者。

Variant