{"id":3079,"date":"2015-08-17T12:10:04","date_gmt":"2015-08-17T03:10:04","guid":{"rendered":"http:\/\/excelwork.info\/excel\/?p=3079"},"modified":"2015-08-17T20:35:29","modified_gmt":"2015-08-17T11:35:29","slug":"classpropertylet","status":"publish","type":"post","link":"https:\/\/excelwork.info\/excel\/classpropertylet\/","title":{"rendered":"Property \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\uff08Property Let \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\uff09"},"content":{"rendered":"<h2>Property \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3<\/h2>\n<div class=\"m30-l\">\n<p><strong>Property \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3<\/strong>\u306f\u3001<span class=\"red\">\u5909\u6570\u3084\u30af\u30e9\u30b9\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\uff08\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u542b\u3080\uff09\u306b\u5bfe\u3057\u3066\u3001\u5024\u306e\u8a2d\u5b9a\u3084\u53d6\u5f97<\/span>\u3092\u884c\u3044\u307e\u3059\u3002\u901a\u5e38\u3001<strong>Property Get \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong> \u3068 <strong>Property Let \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong> \u307e\u305f\u306f\u3001<strong>Property Get \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong> \u3068 <strong>Property Set \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong> \u3092\u30da\u30a2\u3067\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<h3>Property Let \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/h3>\n<p><strong>Property Let \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong>\u306f\u3001\u5909\u6570\u3084\u30af\u30e9\u30b9\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\uff08\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u4ee5\u5916\uff09\u306b\u5024\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u5024\u306e\u53d6\u5f97\u306b\u306f\u3001<strong>Property Get \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong>\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<div class=\"kkbox\"><strong>\u3010\u69cb\u6587\u3011<\/strong><\/p>\n<p>    [ <em>access_level<\/em> ] [ <strong>Static<\/strong> ] <strong>Property<\/strong> <strong>Let<\/strong> <em>name<\/em> ( [ <em>arglist<\/em>,] <em>value<\/em> )<\/p>\n<p>    \u3000\u3000[ <em>statements<\/em> ]<\/p>\n<p>    \u3000\u3000[ <strong>Exit Property<\/strong> ]<\/p>\n<p>    \u3000\u3000[ <em>statements<\/em> ]<\/p>\n<p>    <strong>End Property<\/strong><\/p><\/div>\n<br \/>\n<h4>\u9805\u76ee\u306e\u8aac\u660e<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>access_level&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3092\u5229\u7528\u3067\u304d\u308b\u7bc4\u56f2\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<strong>Public<\/strong>\u30fb<strong>Private<\/strong>\u30fb<strong>Friend<\/strong> \u306e3\u7a2e\u985e\u304c\u3042\u308a\u307e\u3059\u3002\u7701\u7565\u3059\u308b\u3068<strong>Public<\/strong> \u3092\u6307\u5b9a\u3057\u305f\u5834\u5408\u3068\u540c\u3058\u306b\u306a\u308a\u307e\u3059\u3002<\/li>\n<li>name&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5b9a\u7fa9\u3059\u308b <strong>Property Let \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3<\/strong>\u306e\u540d\u524d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u540c\u3058 Class \u30e2\u30b8\u30e5\u30fc\u30eb\u5185\u3067\u3001\u30da\u30a2\u3068\u306a\u308b <strong>Property Get \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3<\/strong>\u306e\u540d\u524d\u3068\u540c\u3058\u306b\u3057\u307e\u3059\u3002<\/li>\n<li>arglist&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;<strong>Property Let \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3<\/strong>\u304c\u547c\u3073\u51fa\u3055\u308c\u308b\u6642\uff08<em>value<\/em>:\u5024 \u304c\u8a2d\u5b9a\u3055\u308c\u308b\u6642\uff09\u306b\u3001<strong>Property Let \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3<\/strong>\u306b\u6e21\u3055\u308c\u308b<strong>\u5f15\u6570\u3092\u8868\u3059\u5909\u6570\u306e\u30ea\u30b9\u30c8<\/strong>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u8907\u6570\u306e\u5909\u6570\u3092\u6307\u5b9a\u3059\u308b\u5834\u5408\u306f\u30ab\u30f3\u30de\uff08,\uff09\u3067\u533a\u5207\u308a\u307e\u3059\u3002\u3053\u306e\u6642\u3001\u5bfe\u5fdc\u3059\u308b <strong>Property Get \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3<\/strong>\u306b\u3082\u3001\u540c\u3058\u540d\u524d\u3068\u6570\u306e <em>arglist<\/em> \u3092\u6307\u5b9a\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<em>arglist<\/em> \u306f\u7701\u7565\u53ef\u80fd\u3067\u3059\u3002<br \/>\n\t\u203b <strong>Property Let \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong> \u306e\u5f15\u6570\u306f\u3001<em>arglist<\/em> \u3068 <em>value<\/em> \u306b\u306a\u308a\u3001<em>value<\/em> \u306f\u7701\u7565\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u5bfe\u5fdc\u3059\u308b <strong>Property Get \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong> \u3088\u308a\u3082\u5f15\u6570\u304c\u5e38\u306b 1 \u3064\u591a\u304f\u306a\u308a\u307e\u3059\u3002<\/li>\n<li>value&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u8a2d\u5b9a\u3059\u308b\u5024\u3092\u683c\u7d0d\u3059\u308b\u5909\u6570\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\uff08\u5fc5\u305a\u6307\u5b9a\u3057\u307e\u3059\u3002\uff09<\/li>\n<li>statements&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5b9f\u884c\u3055\u308c\u308b\u4e00\u9023\u306e\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<br \/>\n<p class=\"caution4\"><em>access_level<\/em>\uff08Public\u30fbPrivate\u30fbFriend\uff09 \u306e\u8a73\u7d30\uff1a<br \/>\n      <strong>Public<\/strong>\uff1a\u3059\u3079\u3066\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u3059\u3079\u3066\u306e\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u304b\u3089\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n      <strong>Private<\/strong>\uff1a\u540c\u4e00\u30e2\u30b8\u30e5\u30fc\u30eb\u5185\u304b\u3089\u306e\u307f\u4f7f\u7528\u53ef\u80fd\u3067\u3059\u3002<br \/>\n      <strong>Friend<\/strong>\uff1a\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u5185\u304b\u3089\u306f\u547c\u3073\u51fa\u305b\u307e\u3059\u304c\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u304b\u3089\u306f\u547c\u3073\u51fa\u305b\u307e\u305b\u3093\u3002\u30ad\u30fc\u30ef\u30fc\u30c9 <strong>Friend<\/strong> \u306f\u3001\u30d5\u30a9\u30fc\u30e0\u30e2\u30b8\u30e5\u30fc\u30eb\u304a\u3088\u3073\u30af\u30e9\u30b9\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u306e\u307f\u8a18\u8ff0\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p class=\"caution4\"><strong>Static<\/strong><br \/>\n      \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u5185\u306e\u30ed\u30fc\u30ab\u30eb\u5909\u6570\u304c\u3001\u6b21\u306b\u547c\u3073\u51fa\u3055\u308c\u308b\u307e\u3067\u305d\u306e\u5024\u3092\u4fdd\u6301\u3057\u307e\u3059\u3002\uff08\u7701\u7565\u53ef\uff09<\/p>\n<p class=\"caution4\"><strong>Exit Property \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8<\/strong>\uff1a<br \/>\nProperty \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3092\u76f4\u3061\u306b\u7d42\u4e86\u3057\u307e\u3059\u3002Exit Property \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u306f\u3001Property \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u5185\u306e\u4efb\u610f\u306e\u5834\u6240\u3067\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u3044\u304f\u3064\u3067\u3082\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002<\/p>\n<\/p><\/div>\n<\/div>\n<br \/><br \/>\n<h2>Property Let \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8 \u4f7f\u7528\u4f8b<\/h2>\n<div class=\"m30-l\">\n<h3 id=\"vba_sample\">\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9 \u305d\u306e\uff11<\/h3>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nPrivate p_num As Double\r\n\r\n'Property Let \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\r\nProperty Let Number(Optional flg As Boolean = True, num)\r\n\r\n    '\u5f15\u6570\uff1aflg \u304c\u3001False \u306e\u5834\u5408\u3001p_num \u3092 0\r\n    If flg = False Then\r\n    \r\n        p_num = 0\r\n    \r\n    End If\r\n\r\n    'num \u304c\u6570\u5024\u306e\u5834\u5408\u3001p_num \u306b\u305d\u306e\u5024\u3092\u52a0\u7b97\r\n    If IsNumeric(num) Then\r\n        \r\n        p_num = p_num + num\r\n\r\n    End If\r\n\r\nEnd Property\r\n\r\n'Property Get \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\r\nProperty Get Number(Optional flg As Boolean = True)\r\n\r\n    Number = p_num\r\n    \r\nEnd Property\r\n\r\n\r\nSub Sample01_Property_Let()\r\n    \r\n    Number = 100\r\n    Debug.Print Number\r\n    \r\n    Number = \"abc\"\r\n    Debug.Print Number\r\n        \r\n    Number = 50.25\r\n    Debug.Print Number\r\n    \r\n    Number = -200\r\n    Debug.Print Number\r\n    \r\n    Number(False) = 0\r\n    Debug.Print Number(False)\r\n\r\nEnd Sub\r\n\u3000\r\n  <\/pre>\n<br \/>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><a href=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/08\/property_let01.jpg?ssl=1\" rel=\"lightbox[3079]\"><img loading=\"lazy\" src=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/08\/property_let01.jpg?resize=400%2C337&#038;ssl=1\" alt=\"Property Let \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3000\u4f8b01\" width=\"400\" height=\"337\" class=\"alignnone size-medium wp-image-3081\" srcset=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/08\/property_let01.jpg?resize=400%2C337&amp;ssl=1 400w, https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/08\/property_let01.jpg?resize=580%2C488&amp;ssl=1 580w, https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/08\/property_let01.jpg?w=773&amp;ssl=1 773w\" sizes=\"(max-width: 400px) 100vw, 400px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<br \/>\n<h3 id=\"vba_sample\">\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9 \u305d\u306e\uff12\uff08\u30af\u30e9\u30b9\uff09<\/h3>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"\u30af\u30e9\u30b9\u30e2\u30b8\u30e5\u30fc\u30eb\uff08\u30af\u30e9\u30b9\u540d\uff1aClass1\uff09\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nPrivate p_Name As String\r\nPrivate p_Age As Long\r\n\r\n'Property Let \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\r\nPublic Property Let Name(str As String)\r\n\r\n    p_Name = str\r\n    \r\nEnd Property\r\n\r\n'Property Get \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\r\nPublic Property Get Name() As String\r\n\r\n    Name = p_Name\r\n\r\nEnd Property\r\n\r\n'Property Let \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\r\nProperty Let Age(num As Long)\r\n\r\n    p_Age = num\r\n\r\nEnd Property\r\n\r\n'Property Get \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\r\nProperty Get Age() As Long\r\n\r\n    Age = p_Age\r\n\r\nEnd Property\r\n\u3000\r\n  <\/pre>\n<br \/>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample02_Property_Let()\r\n\r\n    Dim cc As New Class1\r\n    \r\n    cc.Name = \"\u5c71\u7530\u592a\u90ce\"\r\n    cc.Age = 20\r\n    \r\n    MsgBox cc.Name & \"\u3000\" & cc.Age\r\n    \r\n    Set cc = Nothing\r\n\r\nEnd Sub\r\n\u3000\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\/08\/property_let02.jpg?ssl=1\" rel=\"lightbox[3079]\"><img loading=\"lazy\" src=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/08\/property_let02.jpg?resize=168%2C155&#038;ssl=1\" alt=\"Property Let \u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3000\u4f8b02\" width=\"168\" height=\"155\" class=\"alignnone size-full wp-image-3082\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<\/div>\n<br \/>\n","protected":false},"excerpt":{"rendered":"<p>Property \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3 Property \u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306f\u3001\u5909\u6570\u3084\u30af\u30e9\u30b9\u306e &#8230; <\/p>\n","protected":false},"author":1,"featured_media":3142,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":""},"categories":[500],"tags":[504,501,38,49],"jetpack_featured_media_url":"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/08\/property_let01-400x3371.jpg?fit=400%2C337&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4Ye9i-NF","_links":{"self":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/3079"}],"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=3079"}],"version-history":[{"count":6,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/3079\/revisions"}],"predecessor-version":[{"id":3145,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/3079\/revisions\/3145"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media\/3142"}],"wp:attachment":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media?parent=3079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/categories?post=3079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/tags?post=3079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}