2017-06-26 2 views
0

Ich bin bereits im Vorbeigehen ByRef Variablen erfahren. Ich weiß, dass ich sie sowohl in der Berufung als auch in der angerufenen Prozedur erklären muss (und als dieselbe Art von Kurs). Ich habe das gemacht, bekomme aber trotzdem einen Kompilierfehler.Kompilieren Fehler byref Argument Typ Mismatch

Dies ist der Aufruf, der fehlschlägt: markierte

transition = reply_manager(CommentfirstJSON, a_b_c_d) 

Mit dem variablen a_b_c_d. Es ist ein String und die aufgerufene Funktion erwartet einen String. Was habe ich falsch gemacht?

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 
+0

Sie müssen den Fragen den relevanten Code hinzufügen, anstatt die Leute zu bitten, ein zufälliges Skript mit der Datei herunterzuladen. –

Antwort

1

Das Problem ist, dass Sie denken, dass Sie es als String

Dim a_b_c_d, abcd As String 

Im Gegensatz zu VB.Net erklärt haben, wo beide von ihnen werden nur die zweite ein dh abcd wird als String, in VBA deklariert werden als String deklariert werden. Die erste, d. H. a_b_c_d wird als Variant

deklariert. Sie müssen beide explizit deklarieren.

Dim a_b_c_d As String, abcd As String 
+0

Problem gelöst! Danke - ich habe auch etwas neues gelernt :-) – user3238187

+0

Großartig und auch wie @AlexK. erwähnt, füge relevanten Code zu der Frage hinzu, anstatt nur Links oder Bilder zu setzen :) Da du neu hier bist, habe ich es für dich getan, aber nächstes Mal wirst du diese Anstrengung selbst machen müssen –