{"id":1671,"date":"2015-04-30T08:24:25","date_gmt":"2015-04-29T23:24:25","guid":{"rendered":"http:\/\/excelwork.info\/excel\/?p=1671"},"modified":"2015-04-30T08:24:25","modified_gmt":"2015-04-29T23:24:25","slug":"paramarray","status":"publish","type":"post","link":"https:\/\/excelwork.info\/excel\/paramarray\/","title":{"rendered":"\u5f15\u6570\u3092\u53ef\u5909\u306b\u3059\u308b\uff08 ParamArray \uff09"},"content":{"rendered":"<h2>ParamArray \u30ad\u30fc\u30ef\u30fc\u30c9<\/h2>\n<br \/>\n<div class=\"m30-l\">\n<p><strong>ParamArray \u30ad\u30fc\u30ef\u30fc\u30c9<\/strong>\u3092\u4f7f\u7528\u3059\u308b\u3068\u4efb\u610f\u306e\u6570\u306e\u5f15\u6570\u3092\u6e21\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u69cb\u6587\u3011<\/strong><\/p>\n<p>  <strong>Sub<\/strong> <em>name<\/em> ( [ <em>varname1<\/em> <strong>As<\/strong> <em>varname1_type<\/em>, <em>varname2<\/em> <strong>As<\/strong> <em>varname2_type<\/em>, \u2026, ] <strong>ParamArray<\/strong> <em>varnamelast<\/em> () [ <strong>As<\/strong> <em>varnamelast_type<\/em> ] )<\/p>\n<\/div>\n<br \/>\n<h3>\u3010\u9805\u76ee\u306e\u8aac\u660e\u3011<\/h3>\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>name&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5b9a\u7fa9\u3059\u308b\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\uff08Sub \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u30fbFunction \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306a\u3069\uff09\u306e\u540d\u524d<\/li>\n<li>varname1,varname2&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3092\u547c\u3073\u51fa\u3057\u305f\u3068\u304d\u306b\u5f15\u304d\u6e21\u3059\u5f15\u6570\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u30ab\u30f3\u30de(,)\u3067\u533a\u5207\u3063\u3066\u8907\u6570\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<li>varname1_type,varname2_type&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5f15\u6570 <em>varname1<\/em>,<em>varname2<\/em> \u306e\u30c7\u30fc\u30bf\u578b\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u7701\u7565\u3059\u308b\u3068\u5f15\u6570 <em>varname<\/em> \u306f\u3001\u30d0\u30ea\u30a2\u30f3\u30c8\u578b\uff08Variant\uff09\u3068\u306a\u308a\u307e\u3059\u3002<\/li>\n<li>varnamelast()&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5f15\u6570\uff08\u30d0\u30ea\u30a2\u30f3\u30c8\u578b\uff08Variant\uff09\u306e\u914d\u5217\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>varnamelast_type&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5f15\u6570 <em>varnamelast<\/em>\u306e\u30c7\u30fc\u30bf\u578b\uff08\u30d0\u30ea\u30a2\u30f3\u30c8\u578b\u306e\u307f\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<br \/>\n<p class=\"caution4\">\u8907\u6570\u306e\u5f15\u6570\u3092\u6307\u5b9a\u3059\u308b\u5834\u5408\u3001<strong>ParamArray<\/strong> \u306f<strong>\u6700\u5f8c\u306b\u6307\u5b9a<\/strong>\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\n<\/p>\n<p class=\"caution4\"><strong>ParamArray \u30ad\u30fc\u30ef\u30fc\u30c9<\/strong>\u3092\u4f7f\u7528\u3057\u305f\u5f15\u6570\u306f\u3001<strong>\u30d0\u30ea\u30a2\u30f3\u30c8\u578b\uff08Variant\uff09\u306e\u914d\u5217<\/strong>\u3068\u3057\u3066\u5ba3\u8a00\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002\n<\/p>\n<p class=\"caution4\"><strong>ParamArray \u30ad\u30fc\u30ef\u30fc\u30c9<\/strong>\u3092\u4f7f\u7528\u3057\u305f\u5f15\u6570\u306b\u3001<strong>ByRef<\/strong>\u3001<strong>ByVal<\/strong>\u3001<strong>Optional<\/strong> \u306e\u5404\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\uff08\u305d\u306e\u5f15\u6570\u306f\u3001\u5e38\u306b\u53c2\u7167\u6e21\u3057\u3068\u306a\u308a\u307e\u3059\uff09\u3002\n<\/p>\n<p class=\"caution4\"><strong>ParamArray \u30ad\u30fc\u30ef\u30fc\u30c9<\/strong>\u3092\u4f7f\u7528\u3057\u305f\u5834\u5408\u3001\u5225\u306e\u5f15\u6570\u306b\u5bfe\u3057\u3066\u3001<strong>Optional \u30ad\u30fc\u30ef\u30fc\u30c9<\/strong>\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002\n<\/p>\n<p class=\"caution4\"><strong>ParamArray \u30ad\u30fc\u30ef\u30fc\u30c9<\/strong>\u306f\u3001<strong>Option Base 1 \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong>\u306e\u5f71\u97ff\u3092\u53d7\u3051\u307e\u305b\u3093\u3002<strong>\u914d\u5217\u306e\u6dfb\u3048\u5b57\u306e\u6700\u5c0f\u5024\u306f\u3001\u5e38\u306b\u300c0\u300d<\/strong>\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<\/div>\n<br \/>\n<h2>\u300cParamArray \u30ad\u30fc\u30ef\u30fc\u30c9\u300d\u306e\u4f7f\u7528\u4f8b<\/h2>\n<div class=\"m30-l\">\n<h3 id=\"vba_sample\">\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9<\/h3>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"\u300cParamArray \u30ad\u30fc\u30ef\u30fc\u30c9\u300d\u306e\u4f7f\u7528\u4f8b\" data-url=\"http:\/\/example.co.jp\" >\r\n\r\n\u3000\r\n'-----------------------------------------------------------------\r\nOption Explicit\r\nOption Base 1\r\n'-----------------------------------------------------------------\r\nSub Sample()\r\n\r\n    Dim a, b, c\r\n    a = 10: b = 20: c = 30\r\n\r\n    '\u5f15\u6570\u306f\u5e38\u306b\u53c2\u7167\u6e21\u3057\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\r\n    Call Sample_ParamArray01(a, b, c)\r\n    Debug.Print a                                           '20\r\n    Debug.Print b                                           '40\r\n    Debug.Print c                                           '60\r\n    \r\n    '\u4efb\u610f\u306e\u6570\u306e\u6570\u5024\u306e\u5408\u8a08\u3092\u53d6\u5f97\r\n    Debug.Print Sample_ParamArray02(1, 2, 3, 4, 5)          '15\r\n    Debug.Print Sample_ParamArray02(20, 35, \"\u3042\u3042\")         '55\r\n    Debug.Print Sample_ParamArray02(9.2, -8, #1\/1\/2015#)    '1.2\r\n\r\nEnd Sub\r\n'-----------------------------------------------------------------\r\n' ParamArray \u3092\u4f7f\u7528\uff08\u5f15\u6570\u306e\u5024\u3092\u5168\u30662\u500d\u306b\u3059\u308b\uff09\r\n'-----------------------------------------------------------------\r\nSub Sample_ParamArray01(ParamArray val())\r\n\r\n    Dim i As Long\r\n    MsgBox val(1)       'ParamArray \u306f\u3001Option Base 1 \u306e\u5f71\u97ff\u3092\u53d7\u3051\u306a\u3044\r\n                        '20 \u304c\u8868\u793a\u3055\u308c\u307e\u3059\r\n                        \r\n    For i = LBound(val) To UBound(val)\r\n        val(i) = val(i) * 2\r\n    Next i\r\n \r\nEnd Sub\r\n'-----------------------------------------------------------------\r\n'\u3000ParamArray \u3092\u4f7f\u7528\uff08\u6570\u5024\u306e\u5408\u8a08\uff09\r\n'-----------------------------------------------------------------\r\nFunction Sample_ParamArray02(ParamArray val() As Variant) As Double\r\n    \r\n    Dim v, total As Double\r\n    \r\n    For Each v In val\r\n        If IsNumeric(v) Then\r\n            total = total + v\r\n        End If\r\n    Next v\r\n    \r\n    Sample_ParamArray02 = total\r\n\r\nEnd Function\r\n\r\n\u3000\r\n\r\n<\/pre>\n<br \/>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><a href=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/paramarray00.jpg?ssl=1\" rel=\"lightbox[1671]\"><img loading=\"lazy\" src=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/paramarray00.jpg?resize=400%2C234&#038;ssl=1\" alt=\"ParamArray \u30ad\u30fc\u30ef\u30fc\u30c9 \u4f8b\" width=\"400\" height=\"234\" class=\"alignnone size-medium wp-image-1673\" srcset=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/paramarray00.jpg?resize=400%2C234&amp;ssl=1 400w, https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/paramarray00.jpg?resize=580%2C340&amp;ssl=1 580w, https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/paramarray00.jpg?w=1180&amp;ssl=1 1180w\" sizes=\"(max-width: 400px) 100vw, 400px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<br \/><\/div>\n<br \/><br \/>\n","protected":false},"excerpt":{"rendered":"<p>ParamArray \u30ad\u30fc\u30ef\u30fc\u30c9 ParamArray \u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u7528\u3059\u308b\u3068\u4efb &#8230; <\/p>\n","protected":false},"author":1,"featured_media":1675,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":"\u5f15\u6570\u3092\u53ef\u5909\u306b\u3059\u308b\uff08 ParamArray \uff09"},"categories":[48],"tags":[175,38,176,49],"jetpack_featured_media_url":"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/paramarray00-400x2341.jpg?fit=400%2C234&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4Ye9i-qX","_links":{"self":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1671"}],"collection":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/comments?post=1671"}],"version-history":[{"count":2,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1671\/revisions"}],"predecessor-version":[{"id":1674,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1671\/revisions\/1674"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media\/1675"}],"wp:attachment":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media?parent=1671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/categories?post=1671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/tags?post=1671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}