{"id":1656,"date":"2015-04-29T13:21:30","date_gmt":"2015-04-29T04:21:30","guid":{"rendered":"http:\/\/excelwork.info\/excel\/?p=1656"},"modified":"2015-04-29T13:21:30","modified_gmt":"2015-04-29T04:21:30","slug":"byrefbyval","status":"publish","type":"post","link":"https:\/\/excelwork.info\/excel\/byrefbyval\/","title":{"rendered":"\u5f15\u6570\u306e\u53c2\u7167\u6e21\u3057\u30fb\u5024\u6e21\u3057\uff08 ByRef, ByVal \uff09"},"content":{"rendered":"<h2>\u5f15\u6570\u306e\u300c\u53c2\u7167\u6e21\u3057\u300d\u3068\u300c\u5024\u6e21\u3057\u300d<\/h2>\n<br \/>\n<div class=\"m30-l\">\n<p>\u300c<span class=\"red\"><strong>\u53c2\u7167\u6e21\u3057<\/strong><\/span>\u300d\u3068\u306f\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306b\u5f15\u6570\u3068\u3057\u3066\u5909\u6570\u3092\u6e21\u3059\u65b9\u6cd5\u306e\uff11\u3064\u3067\u3001\u3053\u306e\u5834\u5408\u3001<strong>\u5909\u6570\u304c\u683c\u7d0d\u3055\u308c\u305f\u30a2\u30c9\u30ec\u30b9<\/strong>\u3092\u6e21\u3057\u307e\u3059\u3002\u3053\u306e\u305f\u3081\u3001\u547c\u3073\u51fa\u3055\u308c\u305f\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u5185\u3067\u6e21\u3055\u308c\u305f\u5909\u6570\u306e\u5024\u3092\u5909\u66f4\u3059\u308b\u3068\u3001<strong>\u547c\u3073\u51fa\u3057\u5143\u306e\u5909\u6570\u306e\u5024\u3082\u5909\u66f4\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059<\/strong>\u3002<br \/>\n  \u4e00\u65b9\u3001\u300c<span class=\"red\"><strong>\u5024\u6e21\u3057<\/strong><\/span>\u300d\u3082\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306b\u5f15\u6570\u3068\u3057\u3066\u5909\u6570\u3092\u6e21\u3059\u65b9\u6cd5\u306e\uff11\u3064\u3067\u3059\u304c\u3001\u3053\u3061\u3089\u306f\u3001<strong>\u5909\u6570\u306e\u30b3\u30d4\u30fc<\/strong>\u3092\u6e21\u3057\u307e\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u3001\u547c\u3073\u51fa\u3055\u308c\u305f\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u5185\u3067\u6e21\u3055\u308c\u305f\u5909\u6570\u306e\u5024\u3092\u5909\u66f4\u3057\u3066\u3082<strong>\u547c\u3073\u51fa\u3057\u5143\u306e\u5909\u6570\u306e\u5024\u306f\u5909\u66f4\u3055\u308c\u307e\u305b\u3093<\/strong>\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u69cb\u6587\u3011<\/strong><\/p>\n<p>  <span class=\"red\">\uff1c \u53c2\u7167\u6e21\u3057 \uff1e<\/span><br \/>\n  <strong>Sub<\/strong> <em>name<\/em> ( <strong>ByRef<\/strong> <em>varname<\/em> <strong>As<\/strong> <em>varname_type<\/em> )<\/p>\n<p>  <span class=\"red\">\uff1c \u5024\u6e21\u3057 \uff1e<\/span><br \/>\n  <strong>Sub<\/strong> <em>name<\/em> ( <strong>ByVal<\/strong> <em>varname<\/em> <strong>As<\/strong> <em>varname_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>varname&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\u8907\u6570\u6307\u5b9a\u3059\u308b\u5834\u5408\u306f\u30ab\u30f3\u30de\uff08,\uff09\u3067\u533a\u5207\u308a\u307e\u3059\u3002<\/li>\n<li>varname_type&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5f15\u6570 <em>varname<\/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<\/ul>\n<br \/>\n<p class=\"caution4\"><strong>\u300c\u53c2\u7167\u6e21\u3057\u300d<\/strong>\u306b\u3057\u305f\u3044\u6642\u306f\u3001<span class=\"red\"><strong>ByRef \u30ad\u30fc\u30ef\u30fc\u30c9<\/strong><\/span>\u3092\u3001<strong>\u300c\u5024\u6e21\u3057\u300d<\/strong>\u306b\u3057\u305f\u3044\u6642\u306f\u3001<span class=\"red\"><strong>ByVal \u30ad\u30fc\u30ef\u30fc\u30c9<\/strong><\/span>\u3092\u5f15\u6570 <em>varname<\/em> \u306e\u524d\u306b\u3064\u3051\u307e\u3059\u304c\u3001<span class=\"red\">\u3053\u308c\u3089\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u7701\u7565\u3057\u305f\u5834\u5408\u306f\u3001<strong>\u300c\u53c2\u7167\u6e21\u3057\u300d<\/strong>\u3068\u306a\u308a\u307e\u3059<\/span>\u3002<\/p>\n<\/div>\n<br \/>\n<h2>\u300cByRef \u30ad\u30fc\u30ef\u30fc\u30c9\u300d\u300cByVal \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=\"\u300cByRef \u30ad\u30fc\u30ef\u30fc\u30c9\u300d\u300cByVal \u30ad\u30fc\u30ef\u30fc\u30c9\u300d\u306e\u4f7f\u7528\u4f8b\" data-url=\"http:\/\/example.co.jp\" >\r\n\r\n\u3000\r\nSub Sample()\r\n\r\n    Dim val1, val2, val3\r\n    \r\n    val1 = 125: val2 = 31: val3 = 1\r\n\r\n    '\u53c2\u7167\u6e21\u3057\r\n    Debug.Print Sample_byref(val1)          '250\r\n    Debug.Print val1                        '250\uff08\u5024\u304c\u5909\u66f4\u3055\u308c\u307e\u3059\uff09\r\n    \r\n    '\u5024\u6e21\u3057\r\n    Debug.Print Sample_byval(val2)          '310\r\n    Debug.Print val2                        '31\uff08\u5024\u306f\u5909\u308f\u308a\u307e\u305b\u3093\uff09\r\n    \r\n    '\u7701\u7565\uff08\u53c2\u7167\u6e21\u3057\uff09\r\n    Debug.Print Sample_omission(val3)       '10001\r\n    Debug.Print val3                        '10001\uff08\u5024\u306f\u5909\u66f4\u3055\u308c\u307e\u3059\uff09\r\n\r\nEnd Sub\r\n'---------------------------------------------------------------------------\r\n' \u53c2\u7167\u6e21\u3057\uff08\u30ad\u30fc\u30ef\u30fc\u30c9 ByRef\uff09\u3092\u4f7f\u7528\u3059\u308b\u4f8b\r\n'---------------------------------------------------------------------------\r\nFunction Sample_byref(ByRef myVal)\r\n  \r\n    myVal = myVal * 2\r\n    Sample_byref = myVal\r\n\r\nEnd Function\r\n'---------------------------------------------------------------------------\r\n' \u5024\u6e21\u3057\uff08\u30ad\u30fc\u30ef\u30fc\u30c9 ByVal\uff09\u3092\u4f7f\u7528\u3059\u308b\u4f8b\r\n'---------------------------------------------------------------------------\r\nFunction Sample_byval(ByVal myVal)\r\n\r\n    myVal = myVal * 10\r\n    Sample_byval = myVal\r\n\r\nEnd Function\r\n'---------------------------------------------------------------------------\r\n' \u53c2\u7167\u6e21\u3057\uff08\u30ad\u30fc\u30ef\u30fc\u30c9\u7701\u7565 \uff09\u3092\u4f7f\u7528\u3059\u308b\u4f8b\r\n'---------------------------------------------------------------------------\r\nFunction Sample_omission(myVal)\r\n  \r\n    myVal = myVal + 10000\r\n    Sample_omission = myVal\r\n\r\nEnd Function\r\n\u3000\r\n\r\n<\/pre>\n<br \/>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><a href=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/byrefbyval.jpg?ssl=1\" rel=\"lightbox[1656]\"><img loading=\"lazy\" src=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/byrefbyval.jpg?resize=400%2C292&#038;ssl=1\" alt=\"\u53c2\u7167\u6e21\u3057\u30fb\u5024\u6e21\u3057\u3000\u4f8b\" width=\"400\" height=\"292\" class=\"alignnone size-medium wp-image-1660\" srcset=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/byrefbyval.jpg?resize=400%2C292&amp;ssl=1 400w, https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/byrefbyval.jpg?resize=580%2C423&amp;ssl=1 580w, https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/byrefbyval.jpg?w=856&amp;ssl=1 856w\" sizes=\"(max-width: 400px) 100vw, 400px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<br \/><\/div>\n<br \/><br \/>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u6570\u306e\u300c\u53c2\u7167\u6e21\u3057\u300d\u3068\u300c\u5024\u6e21\u3057\u300d \u300c\u53c2\u7167\u6e21\u3057\u300d\u3068\u306f\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306b\u5f15\u6570\u3068\u3057\u3066\u5909\u6570\u3092\u6e21 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":1663,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":"\u5f15\u6570\u306e\u53c2\u7167\u6e21\u3057\u30fb\u5024\u6e21\u3057\uff08 ByRef, ByVal \uff09"},"categories":[48],"tags":[171,172,38,174,173,49],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/04\/byrefbyval-400x2921.jpg?fit=400%2C292&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4Ye9i-qI","_links":{"self":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1656"}],"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=1656"}],"version-history":[{"count":5,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1656\/revisions"}],"predecessor-version":[{"id":1662,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1656\/revisions\/1662"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media\/1663"}],"wp:attachment":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media?parent=1656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/categories?post=1656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/tags?post=1656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}