{"id":379,"date":"2019-10-21T09:45:53","date_gmt":"2019-10-21T15:45:53","guid":{"rendered":"https:\/\/www.great-white-software.com\/blog\/?p=379"},"modified":"2019-11-19T09:51:15","modified_gmt":"2019-11-19T16:51:15","slug":"byval-and-byref","status":"publish","type":"post","link":"https:\/\/www.great-white-software.com\/blog\/2019\/10\/21\/byval-and-byref\/","title":{"rendered":"ByVal and ByRef"},"content":{"rendered":"\n<p>A recent thread on the forums made it clear there is some lack of clarity about ByVal and ByRef<\/p>\n\n\n\n<p>So here&#8217;s yet another attempt.<\/p>\n\n\n\n<p>Value types are ones that the data assigned to them is stored right IN the memory location the compiler set aside for them. <\/p>\n\n\n\n<p>A statement like<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dim i as integer<\/code><\/pre>\n\n\n\n<p>reserves a spot in memory when you compile. When you later do<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>i = 100<\/code><\/pre>\n\n\n\n<p>the value 100 is put in the spot reserved<\/p>\n\n\n\n<p>For a reference type, one that you create using the NEW keyword, what is reserved by the compiler is a spot to hold the &#8220;address&#8221; of whatever kind of object defined. A statement like<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dim d as Date<\/code><\/pre>\n\n\n\n<p>sets aside a spot to hold the address of a Date. When you later do<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>d = new Date<\/code><\/pre>\n\n\n\n<p>what gets put in the spot that was reserved is not the data for a Date object but the &#8220;address&#8221; of that data &#8211; the reference to the data<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A recent thread on the forums made it clear there is some lack of clarity about ByVal and ByRef So here&#8217;s yet another attempt. Value types are ones that the data assigned to them is stored right IN the memory location the compiler set aside for them. A statement like reserves a spot in memory &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.great-white-software.com\/blog\/2019\/10\/21\/byval-and-byref\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;ByVal and ByRef&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[6,3],"class_list":["post-379","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-tips","tag-xojo"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/379","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/comments?post=379"}],"version-history":[{"count":1,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/379\/revisions"}],"predecessor-version":[{"id":380,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/379\/revisions\/380"}],"wp:attachment":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/media?parent=379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/categories?post=379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/tags?post=379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}