2017-06-26 12 views
0

ByRefの変数を渡した経験があります。私は、呼び出すときと呼ばれるとき(そして同じ種類のコースとして)に宣言しなければならないことを知っています。私はそれをしましたが、まだコンパイルエラーが発生します。マーク変数a_b_c_dコンパイルエラーbyref引数のタイプの不一致

transition = reply_manager(CommentfirstJSON, a_b_c_d) 

これは失敗したコールです。これは文字列であり、呼び出される関数は文字列を要求します。それで私は何を間違えたのですか?

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

ファイルを含むランダムなスクリプトをダウンロードするように質問するのではなく、質問に関連するコードを追加する必要があります。 –

答えて

1

問題は、あなたがそれらの両方が、VBAで、Stringとして宣言されますVB.Netとは異なりString

Dim a_b_c_d, abcd As String 

としてそれを宣言したことを考えることだけ第二1すなわちですabcdますStringと宣言してください。最初の数字はa_b_c_dとなります。Variant

明示的に両方を宣言する必要があります。

Dim a_b_c_d As String, abcd As String 
+0

問題が解決しました!ありがとうございます - 私も何か新しいことを学んだ:-) – user3238187

+0

偉大なまた@AlexKのような。リンクや画像を置くのではなく、関連するコードを質問に追加してください:)あなたがここに新しい人なので、私はあなたのためにそれをしましたが、次回はあなた自身でその努力をしなければなりません –

関連する問題